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

feat(components): add a post-collapsible-trigger #3209

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

alizedebray
Copy link
Contributor

No description provided.

@alizedebray alizedebray requested a review from a team as a code owner July 2, 2024 17:14
@alizedebray alizedebray requested review from gfellerph and removed request for a team July 2, 2024 17:14
Copy link

changeset-bot bot commented Jul 2, 2024

🦋 Changeset detected

Latest commit: cbe8e03

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

This PR includes changesets to release 14 packages
Name Type
@swisspost/design-system-documentation Minor
@swisspost/design-system-components Minor
@swisspost/design-system-components-angular Minor
@swisspost/design-system-components-react Minor
@swisspost/design-system-components-angular-workspace Patch
@swisspost/design-system-nextjs-integration Patch
@swisspost/design-system-styles Minor
@swisspost/design-system-intranet-header Minor
@swisspost/design-system-icons Minor
@swisspost/design-system-migrations Minor
@swisspost/design-system-demo Patch
@swisspost/internet-header Patch
@swisspost/design-system-intranet-header-workspace Patch
@swisspost/design-system-intranet-header-showcase 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

@alizedebray alizedebray self-assigned this Jul 2, 2024
@swisspost-bot
Copy link
Contributor

swisspost-bot commented Jul 2, 2024

Related Previews

@alizedebray alizedebray added the 🚂 PR train PR which follows another one. label Jul 2, 2024
@alizedebray alizedebray force-pushed the 3208-create-post-collapsible-trigger-component branch from 22f6e84 to 6b8095d Compare July 3, 2024 06:45
@alizedebray alizedebray changed the base branch from tooltip-trigger to main July 3, 2024 06:45
@alizedebray alizedebray removed the 🚂 PR train PR which follows another one. label Jul 3, 2024
@alizedebray alizedebray linked an issue Jul 3, 2024 that may be closed by this pull request
@alizedebray alizedebray force-pushed the 3208-create-post-collapsible-trigger-component branch from fb37469 to 7e1bf77 Compare July 3, 2024 13:46
@alizedebray alizedebray force-pushed the 3208-create-post-collapsible-trigger-component branch from 0c0a845 to 5b8d69d Compare July 4, 2024 06:57
Copy link
Member

@gfellerph gfellerph Jul 9, 2024

Choose a reason for hiding this comment

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

The only semantically valid child or slotted element is a single button (it still makes sense to slot it because there are many types of buttons and you'd not want to rebuild the trigger as a button). With this in mind, it would be possible to simplify the code somewhat, because clicks on buttons bubble up through the shadow dom and buttons are focusable anyways.

  • No need for keydown or pointerdown, just listen for click events on the host (https://codepen.io/tuelsch/pen/zYVYgEd?editors=1111)
  • No need to check if it's focusable
  • Check if the slotted element is a button, otherwise warning (on componentDidLoad)
  • Set all aria attributes on the slotted button

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated the PR to make it mandatory to use a <button> inside the trigger. Do you think we should allow the [role="button"] as well?
I also attached the click listener directly to the trigger as I need to query the element to set the ARIA attributes anyways.

Concerning slotted buttons, I am not sure this is a real use case in the end. The component itself does not have a shadow root thus in most cases both the button and the collapsible will be in the light DOM. And if we implement the post-collapsible-trigger into another component, we will most probably also add the button and the collapsible ourselves so they will both be in the shadow DOM. What do you think?
Anyways, if that's okay with you I would rather merge this PR without this feature and potentially handle slotted buttons in the accordion PR since it contains the necessary helpers already.

Copy link
Member

Choose a reason for hiding this comment

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

I think for the moment we can go without role=button support. It's a valid use case, but pretty rare (hopefully). There are many other downsides to not using propper buttons (e.g. role buttons are not focusable by default), therefore we should not "advertise" this use case too much.

As for the slotted button, I think I missed that point in the review, or got confused by the two PRs. I'll review with that in mind again, thanks for the heads up.

@alizedebray alizedebray force-pushed the 3208-create-post-collapsible-trigger-component branch from 2723c96 to 7e0295a Compare July 15, 2024 15:30
Copy link

sonarcloud bot commented Jul 16, 2024

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.

Create post-collapsible-trigger component
3 participants