-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HDS-1975 mobile submenu fixes #1182
Conversation
a8ba12c
to
049bd64
Compare
Check if this PR fixes issue in doc site header examples. If not, a separate ticket should be made. What happens in the video is that the closed mobile menu is shown over the Header. It can't be hidden because then transition animation wouldn't work. Screen.Recording.2023-12-28.at.10.06.17.mov |
049bd64
to
fa46ee6
Compare
Same code was repeated too many times.
Current state based system stores a lot of information in different React states. The menus do not change, just the selected ones. So storing selected menu indexes makes the data structure simpler. State based rendering has problem with data updates. Some rendered data is old until state changes. That's why there is the bug with rendering correct menus when animating.
Menu position can be set immediately. Render count is reduced.
The id was used just for focusing. The id was not very unique, so might conflict.
The menu never had the id that the menu button 's aria-controls refers to.
Moved the drop to the dropdown button
Another PR made the mobileMenu element always visible and animates it vertically.
fa46ee6
to
0ca84bc
Compare
Issue in Harri's video still occurs after this. Ticket was created: https://helsinkisolutionoffice.atlassian.net/browse/HDS-2095 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thumb up from me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
Description
Mobile menu had a few issues:
The
useState
based rendering system was replaced with an index based system, where each selected menu is stored only as an array of data. Previously whole menu contents were stored and therefore updates were not in sync and updated too late.With index based data the rendering does not depend on data in state, and is always up to date. And the code is simpler.
Note: vertical animation came after this PR was initially done and made the animation handling more complicated. This PR is now fixed to handle both animated transforms.
Related Issue
Closes HDS-1975
How Has This Been Tested?
Added missing unit tests. Tested locally.
Demo
See related PR