-
Notifications
You must be signed in to change notification settings - Fork 21
chore(components): update <post-menu> and <post-popovecontainer> to enforce separation of concerns
#6357
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
Merged
myrta2302
merged 72 commits into
main
from
6341-update-post-menu-and-post-popovecontainer-to-enforce-separation
Oct 28, 2025
Merged
chore(components): update <post-menu> and <post-popovecontainer> to enforce separation of concerns
#6357
Changes from 62 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
c113112
chore(post-popovercontainer): remove animate-pop-in class references
hugomslv 0c9b513
chore(post-popovercontainer): remove animate-pop-in class references
hugomslv cb0e11f
Merge branch 'main' into 5463-refactor-post-popovercontainer-animatio…
hugomslv 89fc041
Merge branch 'main' into 5463-refactor-post-popovercontainer-animatio…
hugomslv dd84738
Merge branch 'main' into 5463-refactor-post-popovercontainer-animatio…
hugomslv 58ea300
fix PR comments
hugomslv 4ee5b71
Merge branch '5463-refactor-post-popovercontainer-animation-to-use-we…
hugomslv d881d5e
Update post-popovercontainer.tsx
hugomslv 764dbf6
Merge branch 'main' into 5463-refactor-post-popovercontainer-animatio…
hugomslv b0d1335
assign `role=menuitem` to focusable children
myrta2302 2839a4f
move the role="menu" back to host
myrta2302 b2209a2
trials
myrta2302 d40e5a7
Merge branch 'main' into 5463-refactor-post-popovercontainer-animatio…
hugomslv 69db18c
remove old pop-in animation
hugomslv 8cf3b89
Merge branch 'main' into 5463-refactor-post-popovercontainer-animatio…
hugomslv 75f13b9
add roles on popovercontainer show
myrta2302 1ac1ba9
remove test component
myrta2302 ce4bd25
revert files
myrta2302 cd0ebfb
lint issue
myrta2302 6e62b74
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 3d2f5d7
add changeset
myrta2302 0ae6785
update roles setup on language switcher and options to imrpove acce…
myrta2302 a079fba
Merge branch '5837-bug-accessibility-issues-with-post-menu-trigger-an…
myrta2302 eace006
improve breadcrumb accessibility
myrta2302 9926d50
Update whole-crews-dream.md
myrta2302 8489cb9
Update whole-crews-dream.md
myrta2302 8319dec
replace the language-option test with a language-switch test
myrta2302 55d3c32
Update whole-crews-dream.md
myrta2302 77e7d72
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 2c6605c
language switch remove obsolete roles and aria-label
myrta2302 0e8db36
corrected accessibility error
myrta2302 2348d20
language-switch test update
myrta2302 82ab83b
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 b8bd682
udpate language switch test
myrta2302 7af9341
Merge branch '5837-bug-accessibility-issues-with-post-menu-trigger-an…
myrta2302 e3be8d9
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 58b680b
fix e2e test
myrta2302 62b7649
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 fd02a6d
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 bfed3d7
Merge branch 'main' into 5463-refactor-post-popovercontainer-animatio…
hugomslv 1f6bf00
Update packages/components/src/animations/pop-in.ts
hugomslv 0fea9db
Update packages/components/src/animations/pop-in.ts
hugomslv 5682c4e
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 abc902e
add caption prop to menu
myrta2302 eb8db3e
removed aria-label again as obsolete
myrta2302 61db02f
review comments update
myrta2302 2e0189c
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 36376d6
Merge branch '5463-refactor-post-popovercontainer-animation-to-use-we…
hugomslv 5edd2e7
Merge branch 'main' into 5463-refactor-post-popovercontainer-animatio…
hugomslv 6c340c1
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 bd604c2
add label prop for post-menu
myrta2302 f88d679
update first open check
myrta2302 756185e
update postToggle event payload
myrta2302 5c19472
Merge branch 'main' into 5837-bug-accessibility-issues-with-post-menu…
myrta2302 8b419ca
update popovercontainer events
myrta2302 4358936
Merge remote-tracking branch 'origin/5463-refactor-post-popovercontai…
myrta2302 dacf4a7
update events
myrta2302 40f76b9
restore label and aria set
myrta2302 a62c847
updates first
myrta2302 1405f7c
remove console.logs
myrta2302 4af08a5
remove obsolete role
myrta2302 058f6bf
add changeset vast-onions-return.md
myrta2302 18eed87
update <post-popovercontainer> event names
myrta2302 b35cd7b
Merge branch 'main' into 6341-update-post-menu-and-post-popovecontain…
myrta2302 ea7a6df
remove postHide payload
myrta2302 697390d
update components.d.ts
myrta2302 fe2f062
minor
myrta2302 f9f15ad
review comments update
myrta2302 c156b1c
Merge branch 'main' into 6341-update-post-menu-and-post-popovecontain…
myrta2302 8c3e657
remove console.logs
myrta2302 6ee9b22
restore eventFrom decorators
myrta2302 af7bb1a
Merge branch 'main' into 6341-update-post-menu-and-post-popovecontain…
myrta2302 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@swisspost/design-system-components': patch | ||
| --- | ||
|
|
||
| Updated `<post-popovercontainer>` to emit events: postBeforeShow, postAfterShow, postHide, postBeforeToggle, and postAfterToggle. Updated `<post-menu>` and `<post-tooltip-trigger>` to consume the `onPostAfterToggle` event emitted by `<post-popovercontainer>`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@swisspost/design-system-components': patch | ||
| --- | ||
|
|
||
| Updated `<post-menu>` and `<post-menu-item>` to prevent accessibility roles from being announced before the menu content is visible, and to ensure correct focus behavior on menu items during keyboard navigation when NVDA is running. | ||
|
|
||
| Removed the obsolete `role="menuitem"` from `<post-language-switch>. `<post-language-option>` now assigns `role="listitem"` in case of `variant="list"`, to ensure a correct reference relationship. | ||
|
|
||
| Updated the `<post-breadcrumbs>` component by removing an `aria-label` set on the trigger wrapper `<div>`, which was causing an accessibility error. Also added `role="none"` to the wrapper div to reflect its presentational purpose. |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,179 @@ | ||
| const LANGUAGE_SWITCH_ID = 'decbb10c-2b39-4f47-b67d-337d8111a3ae'; | ||
| const LANGUAGE_OPTION_ID = '3753ab83-a659-47b5-a2f2-ac452ec97916'; | ||
|
|
||
| describe('post-language-switch', () => { | ||
| describe('list variant', () => { | ||
| beforeEach(() => { | ||
| cy.getComponent('language-switch', LANGUAGE_SWITCH_ID); | ||
| }); | ||
|
|
||
| it('should render', () => { | ||
| cy.get('@language-switch').should('exist'); | ||
| }); | ||
|
|
||
| it('should have three language option items', () => { | ||
| cy.get('@language-switch').find('post-language-option').as('language-options'); | ||
| cy.get('@language-options').should('have.length', 3); | ||
| }); | ||
|
|
||
| it('should render as a list', () => { | ||
| cy.get('@language-switch').find('.post-language-switch-list').should('exist'); | ||
| }); | ||
|
|
||
| it('should not render dropdown elements', () => { | ||
| cy.get('@language-switch').find('post-menu-trigger').should('not.exist'); | ||
| cy.get('@language-switch').find('post-menu').should('not.exist'); | ||
| }); | ||
|
|
||
| it('should have the correct ARIA attributes', () => { | ||
| cy.get('@language-switch') | ||
| .find('[role="list"]') | ||
| .should('have.attr', 'aria-label', 'Change the language') | ||
| .and('have.attr', 'aria-describedby'); | ||
|
|
||
| cy.get('@language-switch') | ||
| .find('[aria-describedby]') | ||
| .should('contain.text', 'The currently selected language is English.'); | ||
| }); | ||
|
|
||
| it('should correctly set the active language option on click', () => { | ||
| cy.get('@language-switch') | ||
| .find('post-language-option[code="en"]') | ||
| .should('have.attr', 'active'); | ||
| cy.get('@language-switch') | ||
| .find('post-language-option[code="fr"]') | ||
| .should('have.attr', 'active', 'false'); | ||
| cy.get('@language-switch') | ||
| .find('post-language-option[code="de"]') | ||
| .should('have.attr', 'active', 'false'); | ||
|
|
||
| cy.get('@language-switch').find('post-language-option[code="de"]').click(); | ||
|
|
||
| cy.get('@language-switch') | ||
| .find('post-language-option[code="de"]') | ||
| .should('have.attr', 'active'); | ||
| cy.get('@language-switch') | ||
| .find('post-language-option[code="en"]') | ||
| .should('not.have.attr', 'active', 'false'); | ||
| cy.get('@language-switch') | ||
| .find('post-language-option[code="fr"]') | ||
| .should('not.have.attr', 'active', 'false'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('menu variant', () => { | ||
| beforeEach(() => { | ||
| cy.getComponent('language-switch', LANGUAGE_SWITCH_ID); | ||
| cy.get('@language-switch').invoke('prop', 'variant', 'menu'); | ||
| cy.get('@language-switch').find('post-menu-trigger').as('trigger'); | ||
| }); | ||
|
|
||
| it('should render as a dropdown menu', () => { | ||
| cy.get('@language-switch').find('post-menu-trigger').should('exist'); | ||
| cy.get('@language-switch').find('post-menu').should('exist'); | ||
| }); | ||
|
|
||
| it('should not render list elements', () => { | ||
| cy.get('@language-switch').find('[role="list"]').should('not.exist'); | ||
| }); | ||
|
|
||
| it('should display the active language in the trigger button', () => { | ||
| cy.get('@trigger').should('contain.text', 'en'); | ||
| }); | ||
|
|
||
| it('should show the menu on trigger click', () => { | ||
| cy.get('@trigger').find('button').click(); | ||
| cy.get('@language-switch').find('post-language-option button').should('be.visible'); | ||
| }); | ||
|
|
||
| it('should correctly switch language and hide menu on option click', () => { | ||
| cy.get('@trigger').find('button').click(); | ||
| cy.get('@language-switch').find('post-language-option[code="de"]').click(); | ||
|
|
||
| cy.get('@trigger').should('contain.text', 'de'); | ||
| cy.get('@language-switch').find('post-language-option').should('not.be.visible'); | ||
| }); | ||
|
|
||
| it('should have correct ARIA roles', () => { | ||
| cy.get('@trigger').find('button').click(); | ||
| cy.get('@language-switch').find('post-menu').should('have.attr', 'role', 'menu'); | ||
| cy.get('@language-switch') | ||
| .find('post-language-option') | ||
| .find('button[role="menuitem"]') | ||
| .should('have.length', 2); | ||
| }); | ||
| }); | ||
|
|
||
| describe('language-option', () => { | ||
| describe('button', () => { | ||
| beforeEach(() => { | ||
| cy.getComponent('language-option', LANGUAGE_OPTION_ID); | ||
| cy.get('@language-option').find('button').as('button'); | ||
| }); | ||
|
|
||
| it('should render', () => { | ||
| cy.get('@language-option').should('exist'); | ||
| }); | ||
|
|
||
| it('should not render an anchor', () => { | ||
| cy.get('@language-option').find('a').should('not.exist'); | ||
| }); | ||
|
|
||
| it('should render a button with correct properties', () => { | ||
| cy.get('@button') | ||
| .should('exist') | ||
| .and('have.attr', 'aria-current', 'true') | ||
| .and('have.attr', 'lang', 'en'); | ||
| }); | ||
|
|
||
| it('should emit postChange event when clicked', () => { | ||
| cy.get('@language-option').then($languageOption => { | ||
| $languageOption.on('postChange', cy.spy().as('postChangeSpy')); | ||
| }); | ||
| cy.get('@button').click({ force: true }); | ||
| cy.get('@postChangeSpy').should('have.been.called'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('anchor', () => { | ||
| beforeEach(() => { | ||
| cy.getComponent('language-option', LANGUAGE_OPTION_ID, 'anchor'); | ||
| cy.get('@language-option').find('a').as('anchor'); | ||
| }); | ||
|
|
||
| it('should render', () => { | ||
| cy.get('@language-option').should('exist'); | ||
| }); | ||
|
|
||
| it('should not render a button', () => { | ||
| cy.get('@language-option').find('button').should('not.exist'); | ||
| }); | ||
|
|
||
| it('should render an anchor', () => { | ||
| cy.get('@anchor') | ||
| .should('exist') | ||
| .and('have.attr', 'aria-current', 'page') | ||
| .and('have.attr', 'href', 'https://www.post.ch/en') | ||
| .and('have.attr', 'hrefLang', 'en') | ||
| .and('have.attr', 'lang', 'en'); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Accessibility', () => { | ||
| beforeEach(() => { | ||
| cy.getComponent('language-switch', LANGUAGE_SWITCH_ID); | ||
| cy.get('@language-switch').invoke('prop', 'variant', 'menu'); | ||
| cy.get('@language-switch').find('post-menu-trigger').as('trigger'); | ||
| cy.get('@language-switch').find('post-language-option').as('language-options'); | ||
| }); | ||
|
|
||
| it('Has no detectable a11y violations for all variants', () => { | ||
| cy.get('post-language-switch').as('languageSwitch'); | ||
| cy.get('@languageSwitch').invoke('prop', 'variant', 'menu'); | ||
| cy.checkA11y('#root-inner'); | ||
| cy.get('@languageSwitch').invoke('prop', 'variant', 'list'); | ||
| cy.checkA11y('#root-inner'); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| const duration = 250; | ||
| const easing = 'ease-out'; | ||
|
|
||
| export function popIn(el: Element) { | ||
| if (!el) return; | ||
|
|
||
| return el.animate( | ||
| [ | ||
| { transform: 'scale(0.9)', opacity: 0 }, | ||
| { transform: 'scale(1)', opacity: 1 }, | ||
| ], | ||
| { | ||
| duration, | ||
| easing, | ||
| fill: 'forwards', | ||
| }, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.