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

Add accordion features #518

Merged
merged 9 commits into from
Jan 7, 2025
Merged

Add accordion features #518

merged 9 commits into from
Jan 7, 2025

Conversation

karlsnyder0
Copy link
Contributor

@karlsnyder0 karlsnyder0 commented Jan 3, 2025

  • Add accordion locking
  • Add click summary event, toggle event and toggle blocked event
  • Add open state
  • Add click summary event cancel

IMPORTANT! Cancelable toggle is not supported with browser native details elements. Event listener capture must be used to intercept the event early enough.

Copy link

changeset-bot bot commented Jan 3, 2025

🦋 Changeset detected

Latest commit: d346d76

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

This PR includes changesets to release 1 package
Name Type
@cypress-design/react-accordion Minor

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

Copy link

vercel bot commented Jan 3, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
cypress-design ✅ Ready (Inspect) Visit Preview Jan 7, 2025 7:35pm

Copy link

cypress bot commented Jan 3, 2025

cypress-design    Run #2604

Run Properties:  status check passed Passed #2604  •  git commit a24e5e5fe2 ℹ️: Merge d346d7611595280a9deaf60d17163dd347a9aec8 into 610469ba643ba382987ad5ab07fd...
Project cypress-design
Branch Review karl/accordion-features
Run status status check passed Passed #2604
Run duration 05m 14s
Commit git commit a24e5e5fe2 ℹ️: Merge d346d7611595280a9deaf60d17163dd347a9aec8 into 610469ba643ba382987ad5ab07fd...
Committer Karl Snyder
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 230
View all changes introduced in this branch ↗︎
UI Coverage  10.87%
  Untested elements 189  
  Tested elements 25  
Accessibility  99.37%
  Failed rules  0 critical   1 serious   0 moderate   1 minor
  Failed elements 22  

/**
* If true, prevents the accordion from toggling open or closed.
*/
locked?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

Should this be "disabled"?

Copy link
Contributor Author

@karlsnyder0 karlsnyder0 Jan 6, 2025

Choose a reason for hiding this comment

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

No, it should be locked. Disabled is a different state that shows the component in a disabled state. This allows us to completely lock the component from bring opened.

Comment on lines 83 to 84
onToggle = () => {},
onToggleBlocked = () => {},
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure we should be setting default empty funcs for these props

Copy link
Contributor Author

@karlsnyder0 karlsnyder0 Jan 6, 2025

Choose a reason for hiding this comment

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

They are optional. Are you recommending that we allow them to be undefined and check for that instead of calling the empty fn?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I'll make that change.

@@ -101,16 +102,86 @@ const props = defineProps<{
* removes the content wrapper from the content.
*/
fullWidthContent?: boolean
open?: boolean
Copy link
Member

Choose a reason for hiding this comment

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

isOpen describes this is a boolean

Copy link
Member

@emilyrohrbough emilyrohrbough left a comment

Choose a reason for hiding this comment

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

Should there be locked style updates that go with this to indicate to the users when an accordion cannot expand/collapse? Are you working off of a design?

@karlsnyder0
Copy link
Contributor Author

karlsnyder0 commented Jan 6, 2025

Should there be locked style updates that go with this to indicate to the users when an accordion cannot expand/collapse? Are you working off of a design?

No. The locked state works with components inside the summary. There's no obvious UI indicators.

onClickRet = onClickSummary(event)
}

// TODO: Clone the original event then check propagation.
Copy link
Member

Choose a reason for hiding this comment

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

Is this an open todo?

Copy link
Contributor Author

@karlsnyder0 karlsnyder0 Jan 7, 2025

Choose a reason for hiding this comment

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

It is. The ideal code would clone the original event and link stopPropagation. For now, that's not ideal for the time we have to finish, we'll keep it simple for now and it's not a blocker.

Copy link
Member

Choose a reason for hiding this comment

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

is there an issue to link to track that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No. Actually I'm not sure we need it until we know that we will need it. In other words, it's not absolutely required but I wanted to leave a note in there in case someone wonders why stopPropagation doesn't work.

* Callback triggered when the accordion toggles open or closed.
* @param open - The new open state of the accordion.
*/
onToggle?: (open: boolean) => void
Copy link
Member

Choose a reason for hiding this comment

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

missing open from prop types

Copy link
Contributor Author

@karlsnyder0 karlsnyder0 Jan 7, 2025

Choose a reason for hiding this comment

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

see- React.HTMLProps<HTMLDetailsElement>. It's not missing.

Co-authored-by: Emily Wisniewski (Rohrbough) <[email protected]>
@karlsnyder0 karlsnyder0 merged commit bb8ccd1 into main Jan 7, 2025
14 of 15 checks passed
@karlsnyder0 karlsnyder0 deleted the karl/accordion-features branch January 7, 2025 20:31
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.

3 participants