-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Select all" functionality to multiselect
- Loading branch information
Showing
15 changed files
with
683 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@crowdstrike/ember-toucan-core': patch | ||
'@crowdstrike/ember-toucan-form': patch | ||
--- | ||
|
||
Adds "Select all" functionality to the `Multiselect` via a new component argument. Provide `@selectAllText` to opt-in to the functionality. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
packages/ember-toucan-core/src/-private/components/form/controls/multiselect/select-all.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{{! template-lint-disable require-presentational-children }} | ||
{{#let (unique-id) as |uniqueId|}} | ||
<li | ||
aria-selected={{if @isSelected "true" "false"}} | ||
class="my-0 cursor-default px-2 leading-4 | ||
{{this.styles}} | ||
{{this.className}} | ||
" | ||
data-active={{if @isActive "true" "false"}} | ||
data-multiselect-select-all-option | ||
id="{{@popoverId}}-{{@index}}" | ||
role="option" | ||
{{on "click" this.onClick}} | ||
{{! template-lint-disable no-pointer-down-event-binding }} | ||
{{on "mousedown" this.onMousedown}} | ||
{{on "mouseover" @onMouseover}} | ||
...attributes | ||
> | ||
<div class="border-lines-dark flex w-full items-center gap-2 border-b py-2"> | ||
{{! | ||
We set `tabindex="-1"` here to remove the checkbox from the tab order. | ||
Instead, we allow the user to use the keyboard arrows to "focus" and | ||
make options active. If we remove this line, you'll notice that the | ||
focus returns to the body when tabbing out of the multiautocomplete | ||
component, which is a strange user experience. | ||
Template lint doesn't like us setting tabindex, but we need it here | ||
as we don't want these elements focusable! | ||
}} | ||
{{! template-lint-disable no-nested-interactive }} | ||
<Form::Controls::Checkbox | ||
data-multiselect-select-all-checkbox | ||
id={{uniqueId}} | ||
tabindex="-1" | ||
@isChecked={{@isSelected}} | ||
@isDisabled={{@isDisabled}} | ||
@isIndeterminate={{@isIndeterminate}} | ||
@isReadOnly={{@isReadOnly}} | ||
@value={{@value}} | ||
/> | ||
|
||
<span> | ||
{{yield}} | ||
</span> | ||
</div> | ||
</li> | ||
{{/let}} |
Oops, something went wrong.