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

MudDynamicTabs: Fix disappearing slider with key attribute (#2816) #8110

Merged
merged 2 commits into from Feb 1, 2024

Conversation

gaplin
Copy link
Contributor

@gaplin gaplin commented Jan 30, 2024

Description

Fixes #2816, fixes #8017
I've added key attribute to elements inside the loop responsible for adding panels.
After that slider stays always visible.

How Has This Been Tested?

visually
I've tried to write some unit tests, but I couldn't reproduce the issue using code. Seems like key attribute isn't respected at all in test's context.
I've added example to UnitTests.Viewer just for testing visually.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Before

before.mp4

After

after.mp4

Checklist:

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added bug Something does not work as intended/expected PR: needs review labels Jan 30, 2024
@gaplin gaplin requested a review from mikes-gh January 31, 2024 16:47
@mikes-gh
Copy link
Contributor

Thanks for the PR Before merging this I want to understand why this bug doesn't show up in the docs.
https://mudblazor.com/components/tabs#simple-dynamic-tabs

@gaplin
Copy link
Contributor Author

gaplin commented Jan 31, 2024

This bug only affects situations when you want to use key attribute to preserve state while closing tab.
In the docs there is no such example.
Here is the one which you've provided but with key attached https://try.mudblazor.com/snippet/caQoabHPVyDzdfkr.
If you navigate to the last tab and then close the first one, slider disappears.

Here is another example from discord's help section:
https://try.mudblazor.com/snippet/wuGyEFxaRSGWtKkL
Without key attribute when you navigate to the last tab then turn the switch and scroll down and then close first tab, the state gets reset but slider is visible.

After adding key https://try.mudblazor.com/snippet/mkwouPnPrzdqaBVU state persists but slider disappears.

@mikes-gh
Copy link
Contributor

mikes-gh commented Feb 1, 2024

@gaplin Thanks for digging into this. We appreciate your PR

@mikes-gh mikes-gh removed their request for review February 1, 2024 10:40
@mikes-gh mikes-gh merged commit e5b8c80 into MudBlazor:dev Feb 1, 2024
3 checks passed
@gaplin gaplin deleted the fix/MudTabs-key-usage branch February 1, 2024 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as intended/expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MudTabPanel with @key Removing tabs before the end tab has unexpected behavior with the scroll position.
3 participants