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

Conversation

clintcs
Copy link
Collaborator

@clintcs clintcs commented Nov 15, 2024

🚀 Description

From the changesets:

  • Most component events are now composed. "change", "close", and "toggle" events are still not composed to match native.

  • Tree no longer dispatches an "item-selected" event. It instead dispatches a bubbling "selected" event from the selected Tree Item. The event's target property is set to that Tree Item.

  • Tab Group no longer dispatches a "tab-show". It instead dispatches a bubbling "active" event from the activated Tab. The event's target property is set to that Tab.

📋 Checklist

🔬 How to Test

Your guess is as good as mine! Maybe add a couple event listeners to different components and verify their events. Pay special attention to Tab, Tab Group, and Tree.

📸 Images/Videos of Functionality

N/A

Copy link

changeset-bot bot commented Nov 15, 2024

🦋 Changeset detected

Latest commit: d5b628d

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 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
Contributor

src/tab.group.ts Outdated
this.dispatchEvent(
new CustomEvent('tab-show', {
tab.dispatchEvent(
new Event('active', {
Copy link
Collaborator Author

@clintcs clintcs Nov 15, 2024

Choose a reason for hiding this comment

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

Tab Group (via Tab) dispatches "active" while Tree dispatches "selected". We probably don't need two different names for more or less the same thing. What do you think?

Of the two, I favor "selected" because it doesn't include other connotations, from :active, like "active" does.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Of the two, I favor "selected" because it doesn't include other connotations, from :active, like "active" does.

Same here

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sweet. I'll take it as a followup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Morning + PTO brain. I'll do it with this PR given I'm already changing it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed a commit if you want to take a look.

@clintcs clintcs force-pushed the dispatch-composed-events branch 2 times, most recently from 0440cfd to 926dfb2 Compare November 15, 2024 21:29
expect(event.bubbles).to.be.true;
});

it('dispatches a "clear" event', async () => {
Copy link
Collaborator Author

@clintcs clintcs Nov 15, 2024

Choose a reason for hiding this comment

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

Does anyone remember why we're dispatching a "clear" event instead of "input" and "change" events?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't, no. May be leftover from the original repository when we were still figuring things out. They can get the same information (that something was cleared) from change and input as you were saying, I think. Update away!

Copy link
Collaborator Author

@clintcs clintcs Dec 2, 2024

Choose a reason for hiding this comment

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

Nice. Will do as a followup.

@clintcs clintcs force-pushed the dispatch-composed-events branch 3 times, most recently from 453a2fd to c3cf965 Compare November 15, 2024 21:46
summary: 'method',
detail: 'event: "change" | "input", handler: (event: Event) => void',
detail:
'(event: "change" | "input", handler: (event: Event) => void) => void',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Before

image

After

image

Most component events are now [`composed`](https://developer.mozilla.org/en-US/docs/Web/API/Event/composed).
"change", "close", and "toggle" events are still not composed to match native.
We're happy to deviate from native and make them composed.
So let us know if you have a use case.
Copy link
Collaborator Author

@clintcs clintcs Nov 15, 2024

Choose a reason for hiding this comment

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

No doubt a use case will present itself. Until then I figure we hold the line—however awkward it is. It may turn out that native has a good reason for not composing those events.

@clintcs clintcs marked this pull request as ready for review November 15, 2024 22:02
src/tab.group.ts Outdated
this.dispatchEvent(
new CustomEvent('tab-show', {
tab.dispatchEvent(
new Event('active', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Of the two, I favor "selected" because it doesn't include other connotations, from :active, like "active" does.

Same here

expect(event.bubbles).to.be.true;
});

it('dispatches a "clear" event', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't, no. May be leftover from the original repository when we were still figuring things out. They can get the same information (that something was cleared) from change and input as you were saying, I think. Update away!

src/tab.group.ts Outdated
this.dispatchEvent(
new CustomEvent('tab-show', {
tab.dispatchEvent(
new Event('active', {
Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

@clintcs clintcs force-pushed the dispatch-composed-events branch from 6d6679c to cca0f37 Compare December 2, 2024 16:02
@clintcs clintcs force-pushed the dispatch-composed-events branch from cca0f37 to d5b628d Compare December 6, 2024 13:25
@clintcs
Copy link
Collaborator Author

clintcs commented Dec 6, 2024

Rebased onto main. I'll merge after #493 is merged.

@clintcs clintcs merged commit 9fd8263 into main Dec 9, 2024
7 checks passed
@clintcs clintcs deleted the dispatch-composed-events branch December 9, 2024 13:36
@github-actions github-actions bot mentioned this pull request Dec 9, 2024
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浏览器服务,不要输入任何密码和下载