Repository navigation
Conversation
|
Hi there @bjarnef, thank you for this contribution! 👍 While we wait for the team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:
Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution. If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request. Thanks, from your friendly Umbraco GitHub bot 🤖 🙂 |
There was a problem hiding this comment.
Pull request overview
This PR adds a new <uui-split-button> component to the UUI component library, including registration, implementation, Storybook story, README, and an export from the components barrel so it can be consumed via @umbraco-ui/uui/components/....
Changes:
- Introduces the new
split-buttoncomponent (registration + Lit element implementation). - Adds Storybook documentation (story + README) and a minimal Vitest test.
- Exposes the new component from
src/components/index.ts.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/components/split-button/split-button.ts | Registers <uui-split-button> and exports the element API. |
| src/components/split-button/split-button.element.ts | Implements the split-button element (buttons + popover dropdown + styling). |
| src/components/split-button/split-button.story.ts | Adds Storybook stories demonstrating common states. |
| src/components/split-button/split-button.test.ts | Adds initial unit/a11y test coverage for the component. |
| src/components/split-button/README.md | Documents basic import/usage for the new component. |
| src/components/index.ts | Re-exports the split-button registration for library consumers. |
| @property({ type: Boolean, reflect: true }) | ||
| public get open() { | ||
| return this.#open; | ||
| } | ||
| public set open(value) { | ||
| this.#open = value; | ||
|
|
||
| if (value === true && this.popoverContainerElement) { | ||
| this.openDropdown(); | ||
| } else { | ||
| this.closeDropdown(); | ||
| } | ||
| } |
| @property({ type: Boolean }) | ||
| compact = false; | ||
|
|
||
| @property({ type: Boolean, reflect: true }) | ||
| disabled = false; | ||
|
|
||
| @property({ type: Boolean, attribute: 'hide-expand' }) | ||
| hideExpand = false; |
| openDropdown() { | ||
| // TODO: This ignorer is just needed for JSON SCHEMA TO WORK, As its not updated with latest TS jet. | ||
| // @ts-ignore | ||
| this.popoverContainerElement?.showPopover(); | ||
| this.#open = true; | ||
| } | ||
|
|
||
| closeDropdown() { | ||
| // TODO: This ignorer is just needed for JSON SCHEMA TO WORK, As its not updated with latest TS jet. | ||
| // @ts-ignore | ||
| this.popoverContainerElement?.hidePopover(); | ||
| this.#open = false; | ||
| } | ||
|
|
||
| #onToggle(event: ToggleEvent) { | ||
| // TODO: This ignorer is just needed for JSON SCHEMA TO WORK, As its not updated with latest TS jet. | ||
|
|
||
| // @ts-ignore | ||
| this.open = event.newState === 'open'; | ||
|
|
||
| /*if (this.open) { | ||
| this.dispatchEvent(new UmbOpenedEvent()); | ||
| } else { | ||
| this.dispatchEvent(new UmbClosedEvent()); | ||
| }*/ | ||
| } |
| html`<uui-button | ||
| .look=${this.look} | ||
| .color=${this.color} | ||
| .compact=${this.compact} | ||
| ?disabled=${this.disabled} | ||
| id="dropdown-button" | ||
| popovertarget="dropdown-popover" | ||
| data-mark="open-dropdown"> |
| <umb-popover-layout> | ||
| <slot></slot> | ||
| </umb-popover-layout> |
| /** | ||
| * @element uui-split-button | ||
| */ | ||
| export class UUISplitButtonElement extends LitElement { |
| import './split-button.js'; | ||
| import { html } from 'lit'; | ||
| import { render } from 'vitest-browser-lit'; | ||
| import { axeRun } from '../../internal/test/a11y.js'; | ||
| import { UUISplitButtonElement } from './split-button.element'; | ||
|
|
||
| describe('UUISplitButtonElement', () => { | ||
| let element: UUISplitButtonElement; | ||
|
|
||
| beforeEach(async () => { | ||
| element = render( | ||
| html`<uui-split-button></uui-split-button>`, | ||
| ).container.querySelector('uui-split-button')!; | ||
| await element.updateComplete; | ||
| }); | ||
|
|
||
| it('is defined with its own instance', () => { | ||
| expect(element).toBeInstanceOf(UUISplitButtonElement); | ||
| }); | ||
|
|
||
| it('passes the a11y audit', async () => { | ||
| expect(await axeRun(element)).toHaveNoViolations(); | ||
| }); | ||
| }); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
|
|



Description
Based on discussion: #1133
Split Button seems to be a common concept throughout UI/UX, where the button has an action + additional actions via dropdown.
https://www.nngroup.com/articles/split-buttons/
https://web.dev/articles/building/a-split-button-component
Part of it based on
umb-dropdownhere, but I think the dropdown should act on a button/toggle next to a primary button as examples above.https://github.com/umbraco/Umbraco-CMS/blob/45b4b2a132f92ad034d33e5ccc413415105b4c33/src/Umbraco.Web.UI.Client/src/packages/core/components/dropdown/dropdown.element.ts
Currently it has 1px gap, but there may be a better way to add a border/separator, so it inherits same color as text color and not rely on background color in user interface.
Using two button components ensure we can navigate these via keyboard.
Types of changes
Motivation and context
I think it would be useful in many parts of back office UI, e.g. "Save & Publish" may be primary actions, while popup/dropdown button shows more actions.
Also in collections with one or more actions. Either a regular button if only a single action of just render split button without expand options.
How to test?
Screenshots (if appropriate)
With the new rounding in UI library v2, I think the
compactbutton looks a bit too squeezed:Checklist