feat: add select all button to multi-select-combo-box - #12716
feat: add select all button to multi-select-combo-box#12716sissbruecker wants to merge 15 commits into
Conversation
da79f2b to
2eab5c8
Compare
vaadin-review-bot
left a comment
There was a problem hiding this comment.
Reviewed the changes — left 2 comments.
| Finding | |
|---|---|
| With the dropdown open and the button visible, Tab can never leave the component | |
| role="application" is set on the overlay for every instance, not only when the button is used |
web-padawan
left a comment
There was a problem hiding this comment.
First batch of comments, mostly focused on reviewing tests so far.
| }); | ||
|
|
||
| it('should not submit the surrounding form on Enter', async () => { | ||
| const form = fixtureSync('<form></form>'); |
There was a problem hiding this comment.
nit: we don't generally test form submission explicitly elsewhere, could use simpler checks with event.defaultPrevented like we have in combo-box "enter key behavior" suite.
There was a problem hiding this comment.
The behavior relies on applying type="button", so I replaced everything with that assertion but kept the test title as is to indicate why that attribute is there..
e5eaba4 to
164ac48
Compare
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
164ac48 to
4e16229
Compare
|
|
||
| const { selectAll, deselectAll, selectFiltered, deselectFiltered } = host.__effectiveI18n; | ||
| if (host.filter) { | ||
| button.textContent = this.#allSelected ? deselectFiltered : selectFiltered; |
There was a problem hiding this comment.
idea(non-blocking): while "keep everything in the controller" approach makes sense, one thing that I would personally do differently is to use Lit for rendering the button, its state and listener.
Possible implementation:
// Internal mixin getters, could be potentially beneficial for TestBench
get __selectAllVisible() {
return this.selectAllButtonVisible && !this.readonly && !this.dataProvider;
}
get __selectAllText() {
const { selectAll, deselectAll, selectFiltered, deselectFiltered } = this.__effectiveI18n;
const allSelected = this.__selectAllVisible && this._selectAllController.isEveryFilteredItemSelected();
if (this.filter) {
return allSelected ? deselectFiltered : selectFiltered;
}
return allSelected ? deselectAll : selectAll;
}
// Declared in the mixin, used in MSCB `render()`
_renderSelectAll() {
return html`
<button part="select-all"
type="button"
?hidden="${!this.__selectAllVisible}"
@click="${this.__onSelectAllClick}"
>
${this.__selectAllText}
</button>
`;
}Some notes from prototyping this locally as an experiment:
- No need for listing individual properties in
updated()and calling_selectAllController.update(). - The controller would need to be created in the
constructor()and acceptthisas a host. - The controller still needs reference to the button - can use
querySelectororrefdirective. - The
restoreFocus()would need to be called fromwillIUpdate()before the button gets hidden.
I'd leave it up to you as a possible optional refactor, not necessarily a big improvement.
|



Description
Part of #4590
Related to vaadin/flow-components#4876
Adds an opt-in "Select all" button to
vaadin-multi-select-combo-box:selectAllButtonVisibleis set, a button is rendered at the top of the dropdown overlay, above the item list.i18n.Implementation notes
selectAllButtonVisibleproperty and theselectAll,deselectAll,selectFilteredanddeselectFilteredi18n keysselect-allshadow part with base, Lumo and Aura styles. It does not useselect-all-buttonas that conflicts with existing styling rules for clear and toggle buttons.SelectAllControllerinselect-all-controller.js. It is not exported from the package and has no.d.ts, following the dashboard controllers. The mixin callsupdate()fromupdated()whenever a property the button depends on has changed.role="listbox"scroller and does not affectaria-activedescendanthandling.__updateSelection(), sochange,selected-items-changedand validation behave exactly as they do for clicking a single item._shouldSetFocusand_shouldRemoveFocus. Only the button shows a focus ring while it is focused, the host drops itsfocus-ringattribute but keepsfocused.Limitations
itemsAPI only. Support fordataProvidercomes as a follow-up.Type of change