Skip to content
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

Merged
merged 10 commits into from
Jan 16, 2024
Merged

HDS-1975 mobile submenu fixes #1182

merged 10 commits into from
Jan 16, 2024

Conversation

NikoHelle
Copy link
Contributor

@NikoHelle NikoHelle commented Dec 4, 2023

Description

Mobile menu had a few issues:

  • when navigating back the active links were first old and then updated after animation
  • unused menus were rendered
  • unnecessary re-renders
  • axe errors

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

@laurakarhu laurakarhu requested review from a team December 5, 2023 13:16
@NikoHelle NikoHelle added the waiting-for-accessibility-audit Issue or request is waiting for an accessibility audit. label Dec 7, 2023
@NikoHelle NikoHelle force-pushed the HDS-1975-submenu-fix branch 3 times, most recently from a8ba12c to 049bd64 Compare December 27, 2023 13:00
@harriplappalainen
Copy link
Contributor

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

@NikoHelle NikoHelle force-pushed the HDS-1975-submenu-fix branch from 049bd64 to fa46ee6 Compare January 8, 2024 11:58
@NikoHelle NikoHelle removed the waiting-for-accessibility-audit Issue or request is waiting for an accessibility audit. label Jan 8, 2024
@NikoHelle NikoHelle marked this pull request as ready for review January 8, 2024 12:11
@NikoHelle NikoHelle marked this pull request as draft January 8, 2024 13:09
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.
Another PR made the mobileMenu element always visible and animates it vertically.
@NikoHelle NikoHelle force-pushed the HDS-1975-submenu-fix branch from fa46ee6 to 0ca84bc Compare January 8, 2024 13:17
@NikoHelle NikoHelle marked this pull request as ready for review January 8, 2024 13:25
@NikoHelle
Copy link
Contributor Author

Issue in Harri's video still occurs after this. Ticket was created: https://helsinkisolutionoffice.atlassian.net/browse/HDS-2095

Copy link
Contributor

@Riippi Riippi left a 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

Copy link
Contributor

@mrTuomoK mrTuomoK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff!

@NikoHelle NikoHelle merged commit c92e5be into development Jan 16, 2024
6 checks passed
@NikoHelle NikoHelle deleted the HDS-1975-submenu-fix branch January 16, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants