-
Notifications
You must be signed in to change notification settings - Fork 7
feat(Drawer): add open
attribute
#497
Conversation
🦋 Changeset detectedLatest commit: 74c65c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
open
attribute
dea9ab5
to
3bdfa91
Compare
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.
Screen.Recording.2024-12-02.at.7.06.26.PM.mov
Code looks good to me, but I seem to find myself in a weird spot if I spam the open
attribute toggle. I hit this by accident with hitting the spacebar initially and then the Drawer got stuck in this weird position.
Maybe not a real life scenario, but I'm wondering if this is a simple fix? It looks like the aside
keeps both the closing open
classes on the element no matter the open
attribute once it gets in this state, so then it's stuck. What do you think?
.changeset/lazy-geese-argue.md
Outdated
'@crowdstrike/glide-core': patch | ||
--- | ||
|
||
Adds an `open` attribute to Drawer. |
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.
Super nit to help with reader/consumer information rather than sounding specific to us:
Adds an `open` attribute to Drawer. | |
Drawer now supports an `open` attribute. |
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.
Updated
src/drawer.test.basics.ts
Outdated
html`<glide-core-drawer>Drawer content</glide-core-drawer>`, | ||
); | ||
|
||
expect(component.shadowRoot?.querySelector('aside[data-test-state="closed"]')) |
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.
Super nit, no need to change, but I think you could use the data-test-
selector itself and drop the aside
if you'd like:
expect(component.shadowRoot?.querySelector('aside[data-test-state="closed"]')) | |
expect(component.shadowRoot?.querySelector('[data-test-state="closed"]')) |
Adding aside
is a bit more explicit to make sure the data-test-state
is coming from there though 🤷
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.
Updated
src/drawer.test.basics.ts
Outdated
|
||
await elementUpdated(component); | ||
|
||
expect(component.shadowRoot?.querySelector('aside[data-test-state="open"]')) |
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.
Similar nit to above:
expect(component.shadowRoot?.querySelector('aside[data-test-state="open"]')) | |
expect(component.shadowRoot?.querySelector('[data-test-state="open"]')) |
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.
Updated
src/drawer.test.basics.ts
Outdated
html`<glide-core-drawer open>Drawer content</glide-core-drawer>`, | ||
); | ||
|
||
expect(component.shadowRoot?.querySelector('aside[data-test-state="open"]')) |
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.
expect(component.shadowRoot?.querySelector('aside[data-test-state="open"]')) | |
expect(component.shadowRoot?.querySelector('[data-test-state="open"]')) |
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.
Updated
src/drawer.test.basics.ts
Outdated
|
||
await elementUpdated(component); | ||
|
||
expect(component.shadowRoot?.querySelector('aside[data-test-state="closed"]')) |
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.
expect(component.shadowRoot?.querySelector('aside[data-test-state="closed"]')) | |
expect(component.shadowRoot?.querySelector('[data-test-state="closed"]')) |
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.
Updated
I suspect this issue has always been there and that the reason is multiple |
pinned: false, | ||
'--width': '', | ||
open: false, |
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.
Mind moving open
and pinned
above show()
so they're in alphabetical order?
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.
Updated
Edit: Missed comiting this, will be in follow-up
@ynotdraw I believe I have a solution to this issue. I'll create a follow-up pr. |
Sounds good, thanks @dylankcrwd ! |
🚀 Description
Adds an
open
attribute to the drawer component.Resolves an issue in
main
where, in the drawer story, the "toggle" button must be clicked twice in order to re-open the drawer after pressing the escape key.📋 Checklist
🔬 How to Test
To test the
open
attribute and property:glide-core-drawer
component and add theopen
attribute. Observe that the drawer opens.open
attribute and observe that the drawer closes.glide-core-drawer
open
property totrue
and observe that the drawer opens.glide-core-drawer
open
property tofalse
and observe that the drawer closes.To test the escape key issue in the story:
main
).📸 Images/Videos of Functionality
open
attribute:Screen.Recording.2024-12-02.at.3.46.57.PM.mov
Storybook escape issue before:
Screen.Recording.2024-12-02.at.3.49.47.PM.mov
Storybook after:
Screen.Recording.2024-12-02.at.3.57.04.PM.mov