+
Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Conversation

dylankcrwd
Copy link
Contributor

@dylankcrwd dylankcrwd commented Dec 2, 2024

🚀 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:

  1. In Storybook, navigate to the Drawer story.
  2. Select the glide-core-drawer component and add the open attribute. Observe that the drawer opens.
  3. Continuing on from step (2), remove the open attribute and observe that the drawer closes.
  4. In the console, set the glide-core-drawer open property to true and observe that the drawer opens.
  5. Continuing on from step (4), set the glide-core-drawer open property to false and observe that the drawer closes.

To test the escape key issue in the story:

  1. In Storybook, navigate to the Drawer story and open it.
  2. Press escape, allowing for the drawer to close, then press the "toggle" button once. Observe that the drawer opens without needing to press the button twice (as is the case in 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

Copy link

changeset-bot bot commented Dec 2, 2024

🦋 Changeset detected

Latest commit: 74c65c2

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

This PR includes changesets to release 1 package
Name Type
@crowdstrike/glide-core 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

@dylankcrwd dylankcrwd changed the title feat(Drawer): add "open" attribute feat(Drawer): add open attribute Dec 2, 2024
Copy link
Contributor

github-actions bot commented Dec 2, 2024

@dylankcrwd dylankcrwd force-pushed the add-drawer-open-attribute branch from dea9ab5 to 3bdfa91 Compare December 2, 2024 20:39
@dylankcrwd dylankcrwd marked this pull request as ready for review December 2, 2024 21:05
Copy link
Collaborator

@ynotdraw ynotdraw left a 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?

Screenshot 2024-12-02 at 7 08 33 PM

'@crowdstrike/glide-core': patch
---

Adds an `open` attribute to Drawer.
Copy link
Collaborator

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:

Suggested change
Adds an `open` attribute to Drawer.
Drawer now supports an `open` attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

html`<glide-core-drawer>Drawer content</glide-core-drawer>`,
);

expect(component.shadowRoot?.querySelector('aside[data-test-state="closed"]'))
Copy link
Collaborator

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:

Suggested change
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 🤷

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated


await elementUpdated(component);

expect(component.shadowRoot?.querySelector('aside[data-test-state="open"]'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar nit to above:

Suggested change
expect(component.shadowRoot?.querySelector('aside[data-test-state="open"]'))
expect(component.shadowRoot?.querySelector('[data-test-state="open"]'))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

html`<glide-core-drawer open>Drawer content</glide-core-drawer>`,
);

expect(component.shadowRoot?.querySelector('aside[data-test-state="open"]'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
expect(component.shadowRoot?.querySelector('aside[data-test-state="open"]'))
expect(component.shadowRoot?.querySelector('[data-test-state="open"]'))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated


await elementUpdated(component);

expect(component.shadowRoot?.querySelector('aside[data-test-state="closed"]'))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
expect(component.shadowRoot?.querySelector('aside[data-test-state="closed"]'))
expect(component.shadowRoot?.querySelector('[data-test-state="closed"]'))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@dylankcrwd
Copy link
Contributor Author

dylankcrwd commented Dec 3, 2024

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?

I suspect this issue has always been there and that the reason is multiple transistionend events & listeners are fired close in time. The approach to animating this would need to change (e.g. web animation api). I'll look into it.

Comment on lines 104 to +106
pinned: false,
'--width': '',
open: false,
Copy link
Collaborator

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?

Copy link
Contributor Author

@dylankcrwd dylankcrwd Dec 3, 2024

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

@dylankcrwd
Copy link
Contributor Author

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?

I suspect this issue has always been there and that the reason is multiple transistionend events & listeners are fired close in time. The approach to animating this would need to change (e.g. web animation api). I'll look into it.

@ynotdraw I believe I have a solution to this issue. I'll create a follow-up pr.

@dylankcrwd dylankcrwd merged commit 37df083 into main Dec 3, 2024
7 checks passed
@dylankcrwd dylankcrwd deleted the add-drawer-open-attribute branch December 3, 2024 16:18
@github-actions github-actions bot mentioned this pull request Dec 3, 2024
@ynotdraw
Copy link
Collaborator

ynotdraw commented Dec 3, 2024

Sounds good, thanks @dylankcrwd !

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载