-
Notifications
You must be signed in to change notification settings - Fork 3
feat(split button): adds split button #207
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
🦋 Changeset detectedLatest commit: 9e906ca 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 |
f764353
to
e33d283
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.
Looks good @dylankcrwd ! A few questions/comments.
One other thing comes to mind, I imagine design already approved, but with the small variant should the dropdown arrow also change sizing? Without it, the chevron down is larger than the text. Curious what design thinks.

border-radius: var(--glide-core-spacing-sm) 0 0 | ||
var(--glide-core-spacing-sm); |
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.
Bummer we don't have a --glide-core-border-radius
that matches this. I'm a bit hesitant on us using spacing values for border radii. I'd maybe prefer just hardcoding these values instead of using spacing-sm
here, because if that value changes for spacing, it would adjust the radii here. What do y'all think?
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.
Since this was copied from glide-core-button
, should that change as well?
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 would probably say so, yeah. I think it's safer for us. Thanks for looking at glide-core-button
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.
Updated glide-core-button
} | ||
|
||
// Can't disable `glide-core-menu`, so capture the event before it arrives. | ||
// Disabling the trigger button doesn't resolve the issue. |
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.
Is this a bug potentially with Menu @clintcs ? I guess maybe not, since the menu doesn't necessarily know if the target it is referencing is disabled or not. And maybe determining that from within menu would be tricky?
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 could see it being Menu's responsibility to check if the target is a child of an element with a disabled
property and return early if so.
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.
Shall we file a task for this or what do you think? Is it a quick update that we could roll into this PR? Then we could remove some code here and get a nice bonus in Menu with this PR?
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 would prefer to make it a separate task I could do in the next sprint, otherwise I fear this card won't get done in time and since I'm OOO for much of next week, the branch will go quite stale.
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 leave it to you two. The work is done on my side. I can push a commit or open a separate PR.
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.
@clintcs If you have a commit with the desired change could you please push it to this branch? Thanks!
I can then remove the click interception logic and related test.
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.
Sweet. I'll push the commit shortly.
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.
@dylankcrwd: Go ahead and merge as is. Filling test gaps in Menu and accounting for the case where disabled
is removed from the target have resulted in a big diff.
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.
Thank you @clintcs
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.
@dylankcrwd: See the comment on my Menu PR for context. I rebased your branch onto main
to bring in my changes and then pushed a commit removing your workaround for Menu. You should be good.
In rebasing I amended this branch's history. So locally you'll need to fetch and then git reset --hard origin/add-split-button
.
href=${ifDefined(this.url)} | ||
class=${classMap({ | ||
component: true, | ||
disabled: this.disabled, |
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.
For a11y reasons, when a link should be disabled, we actually render a <span>
with some attributes instead. That way the component appears visually disabled, but then we don't have an underlying <a
that we have to intercept click handlers for and it also announces to screenreaders as one would expect.
This happened in one of our other private repos (you know the one!) with main-navigation-link.ts
if you take a look there. We should probably follow the same pattern here as that was blessed by Noah from an a11y standpoint.
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.
Will look into this
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.
To be consistent with a disabled button, the span is not tabbable when disabled, unlike main-navigation-link.ts
. Let me know if this is what you're looking for.
This looks to be consistent with The split button has been approved, however there is nothing that I've seen in the figma for the small size and was something I added to be consistent with the button. |
Oh. If this is the case, I don't think we want to add sizing for this component. I'd double check with Mary, Joe, or Zheng. We only want to add support for things we know design explicitly calls for. So even though Button supports a size, there may not be needs for a small SplitButton, so we shouldn't add it. |
I asked the question of Design & |
border-color: transparent; | ||
color: var(--glide-core-text-selected); | ||
|
||
&.disabled { |
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.
Could be good to add a comment on why this uses .disabled
versus :disabled
(because of the shared usage of buttons and links) for future travelers.
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.
The comment is just above on line 37, but I can move it down.
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
?.dispatchEvent(event); | ||
|
||
await elementUpdated(component); | ||
|
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.
Since the test reads "remains closed when clicked", should we verify once again that the menu is in fact closed and not open? Similar to what you have in the next test at the bottom.
expect( | |
component.shadowRoot?.querySelector('glide-core-menu'), | |
).to.not.have.attribute('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
expect(link?.classList.contains('secondary')).to.be.true; | ||
}); | ||
|
||
it('becomse a span when the "disabled" attribute exists', async () => { |
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.
Typo:
it('becomse a span when the "disabled" attribute exists', async () => { | |
it('becomes a span when the "disabled" attribute exists', async () => { |
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
); | ||
}); | ||
|
||
it('throws an error when there is something other than text is in the default slot', async () => { |
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.
A small typo:
it('throws an error when there is something other than text is in the default slot', async () => { | |
it('throws an error when there is something other than text in the default slot', async () => { |
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
Adds
glide-core-split-container
,glide-core-split-button
, andglide-core-split-link
.Storybook: https://glide-core.crowdstrike-ux.workers.dev/add-split-button?path=/docs/split-button--overview