-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat(s2): update accordion api to allow sibling elements in disclosure header #7179
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API and styles look good.
style={UNSAFE_style} | ||
className={(UNSAFE_className ?? '') + style({display: 'flex', alignItems: 'center', gap: 4})} | ||
ref={domRef}> | ||
{children} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An option for shorthand: if typeof children === 'string'
, we could automatically wrap children
in a DisclosureTrigger
, which would let you use our existing API as well.
No need to implement this now, we could discuss it later
I'll update the chromatic stories as well once we settle on the API that we like |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -34,15 +36,19 @@ export const Example: Story = { | |||
<Accordion {...args}> | |||
<Disclosure id="files"> | |||
<DisclosureHeader> | |||
Files | |||
<DisclosureTrigger> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern is opposite to our other triggers
<DialogTrigger>
is the outermost, whereas here, DisclosureTrigger
is the innermost
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because the header can contain elements that are not part of the trigger (eg adjacent buttons).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that, but it also doesn't include the element that it opens like our other triggers
See my other concerns in my next comment down about level
}; | ||
|
||
// maps to one size smaller in the compact density to ensure there is space between the top and bottom of the action button and container | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'll take a look at this later, just wanted to get the lint working for testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was the error?
My only question is whether we want to have a shortcut so you don't need to write |
Does it make more sense to have |
But then as soon as you put a |
This is true. I guess I'm ok with it. I don't have a better idea. |
}; | ||
|
||
// maps to one size smaller in the compact density to ensure there is space between the top and bottom of the action button and container | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what was the error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE seems to have been a cache issue, I can't reproduce in incognito
Seeing an error when I try to visit the storybook build https://reactspectrum.blob.core.windows.net/reactspectrum/844be69102b36467a58c5be2e1aaee9e90d50c48/storybook/index.html?path=/story/accordion--default&providerSwitcher-express=false
Not seeing the error on Main, but this only have changes for s2... so I'm not sure what has changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we doing the auto wrapping in a followup?
i'll just do it in this pr. i'd like to get the api figured out so that i can update the chromatic stories too |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of scope. Shouldn't there be an example with an expanded disclosure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like a style got lost somewhere?
https://www.chromatic.com/build?appId=5f0dd5ad2b5fc10022a2e320&number=807
actually, looks like I can't interact with/open the disclosure anymore for some of these
ah good catch. i think that's because i forgot to update the chromatic stories to use
which one's specifically can you not interact with/open and which browser? im not able to reproduce |
## API Changes
@react-spectrum/s2/@react-spectrum/s2:DisclosureHeader DisclosureHeader {
UNSAFE_className?: string
UNSAFE_style?: CSSProperties
children: React.ReactNode
id?: string
- level?: number = 3
} /@react-spectrum/s2:DisclosureTitle+DisclosureTitle {
+ UNSAFE_className?: string
+ UNSAFE_style?: CSSProperties
+ children: React.ReactNode
+ id?: string
+ level?: number = 3
+} |
This is the chromatic story where i couldn't open it https://5f0dd5ad2b5fc10022a2e320-ykjpggsppc.chromatic.com/?path=/story/s2-chromatic-disclosure--example which is explained by not using the right elements. It's fixed now with your updates. |
Closes
✅ Pull Request Checklist:
📝 Test Instructions:
🧢 Your Project: