Skip to content

Conversation

@milan-w
Copy link
Contributor

@milan-w milan-w commented Oct 30, 2025

Set (aria-)selected state via listener on parent tablist to also react on de-selection of item. Closes #5288

Proposed changes

Each tab item holds an internal state _selected to keep track of the active tab. However before this change the state function did not correctly react to a de-selection because the event was only triggered on the newly active tab.
Now each item registers an event listener on the parent component and sets de/selected according to this event.

The playwright test for the tab components has also been refactored slightly to eliminate an unneccesary file write process.

Types of changes

  • Bugfix (non-breaking change that fixes an issue)

  • New feature (non-breaking change which adds functionality)

  • Refactoring (improvements to existing components or architectural decisions)

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

  • Documentation Update (if none of the other choices apply)

  • I have added tests that prove my fix is effective or that my feature works

  • I have added necessary documentation (if appropriate)

🔭🐙🐈 Test this branch here: https://design-system.deutschebahn.com/core-web/review/fix-tab-item-selected-state

@changeset-bot
Copy link

changeset-bot bot commented Oct 30, 2025

🦋 Changeset detected

Latest commit: d3c5b8d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 9 packages
Name Type
@db-ux/core-components Patch
@db-ux/ngx-core-components Patch
@db-ux/react-core-components Patch
@db-ux/wc-core-components Patch
@db-ux/v-core-components Patch
@db-ux/core-foundations Patch
@db-ux/core-stylelint Patch
@db-ux/core-migration Patch
@db-ux/agent-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@milan-w milan-w requested review from mfranzke and nmerget October 30, 2025 19:29
@github-actions github-actions bot added 🏘components 📕documentation Improvements or additions to documentation labels Oct 30, 2025
d-koppenhagen
d-koppenhagen previously approved these changes Oct 31, 2025
props.onChange(event);
}

// We have different ts types in different frameworks, so we need to use any here
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can keep this - the aria snapshots changed so it might be good to keep those additonally

milan-w and others added 7 commits November 4, 2025 15:55
Set (aria-)selected state via listener on parent tablist to also react on de-selection of item.
use var instead of file to hold click event results for test duration
Now also sets aria-selected=true|false correctly which improves screen reader behaviour.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
set child active after event registered, remove event listerner on unmount
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
add more checks and guardrails to TabItem on change events
@milan-w milan-w force-pushed the fix-tab-item-selected-state branch from ee7cfbe to d1535e1 Compare November 6, 2025 17:11
@milan-w milan-w requested a review from nmerget November 7, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🏘components 📕documentation Improvements or additions to documentation

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

Tabs selected state incorrect

4 participants