Skip to content
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

Add Combobox component to Toucan Core & Toucan Form #200

Merged
merged 86 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
8e47606
feat: Add Form::Controls::Select
clintcs Jun 14, 2023
0ce8422
fix: add placeholder styling
clintcs Jun 28, 2023
82c2e54
chore: post-rebase tweaks
clintcs Jun 28, 2023
6b70b36
fix: Escape should never open the popover
clintcs Jun 28, 2023
bc9f129
chore: add note about scrollbar styling
clintcs Jun 28, 2023
d2eb4d7
fix: shift arrow over
clintcs Jun 28, 2023
1d9469f
chore: styling tweaks
clintcs Jun 28, 2023
c9ea2b9
fix: add z-index to demo
clintcs Jun 28, 2023
7bd75dc
fix: styling tweaks
clintcs Jun 28, 2023
ae985f2
chore: remove active descendant support
clintcs Jun 28, 2023
98a4ff5
Fix a11y issues and move to new API
ynotdraw Jun 30, 2023
b17059e
toucan-core: Add filtering
ynotdraw Jul 3, 2023
0370e0b
toucan-core: Add custom filtering
ynotdraw Jul 3, 2023
aa8ed2a
toucan-core: Move selected logic into Select root
ynotdraw Jul 3, 2023
761b63c
toucan-core: Remove out of date docs
ynotdraw Jul 5, 2023
7bce810
toucan-core: Prettier docs
ynotdraw Jul 5, 2023
245430b
toucan-core: Add optionKey and onFilter
ynotdraw Jul 5, 2023
b9a74d3
toucan-core: Fix filteredOptions logic
ynotdraw Jul 5, 2023
8532fee
toucan-core: Use ember-is-equal
ynotdraw Jul 5, 2023
4cf92e4
toucan-core: Reset input to selection on blur
ynotdraw Jul 5, 2023
c2e1975
toucan-core: Handle tab+backspace keyboard events
ynotdraw Jul 5, 2023
997ca0f
toucan-core: Remove unused component args
ynotdraw Jul 5, 2023
8221150
toucan-core: Fix up SelectField component
ynotdraw Jul 5, 2023
9aaefd6
toucan-core: Add type="text"
ynotdraw Jul 5, 2023
e8ab8f4
toucan-core: JSDoc for select control
ynotdraw Jul 5, 2023
195cdec
toucan-core: Add lock icon
ynotdraw Jul 5, 2023
71c14fe
docs: Rename select single to base-demo
ynotdraw Jul 5, 2023
9062d64
docs: Update documentation with latest args
ynotdraw Jul 5, 2023
49ace8d
docs: Update selectfield docs
ynotdraw Jul 5, 2023
a9008c6
toucan-core: Set input value on render
ynotdraw Jul 5, 2023
687d740
toucan-core: Disable no-redundant-role on input
ynotdraw Jul 5, 2023
95619b5
toucan-core: Re-opening should clear filtered options
ynotdraw Jul 5, 2023
30a74b2
toucan-core: Use deep equality check
ynotdraw Jul 5, 2023
0914dae
toucan-core: Reselect text input on click, remove backspace logic
ynotdraw Jul 5, 2023
dce0071
toucan-core: Add noResultsText
ynotdraw Jul 5, 2023
5c0dd09
toucan-core: Adjust optionElement logic
ynotdraw Jul 5, 2023
b89bb5f
docs: Remove placeholder in demo
ynotdraw Jul 5, 2023
38a5e2c
toucan-core: Remove option chaining
ynotdraw Jul 5, 2023
afc288f
toucan-core: Allow space key to be entered
ynotdraw Jul 6, 2023
c2ec6ca
docs: Add noResultsText to select-field
ynotdraw Jul 6, 2023
00bd8bf
toucan-core: Adjust list option styling to match designs
ynotdraw Jul 6, 2023
41dfc34
Revert "toucan-core: Allow space key to be entered"
ynotdraw Jul 6, 2023
334c470
toucan-core: Allow space key to be entered
ynotdraw Jul 6, 2023
60e11ea
docs: Remove unused component arg
ynotdraw Jul 6, 2023
1a0b7f4
cleanup: Remove TODO comments
ynotdraw Jul 6, 2023
4cafbfc
Add SelectField to template-registry
ynotdraw Jul 6, 2023
0692f97
toucan-form: Wire up select-field to work with ToucanForm
ynotdraw Jul 6, 2023
0cdcc84
Rename from select to combobox
ynotdraw Jul 6, 2023
70bbaf9
toucan-core: Remove redundant class
ynotdraw Jul 6, 2023
41356a3
Revert "toucan-core: Remove redundant class"
ynotdraw Jul 6, 2023
6421232
toucan-core: Remove redundant class
ynotdraw Jul 6, 2023
228c135
toucan-core: Move splattributes to li element instead
ynotdraw Jul 6, 2023
9adfbf6
tests: Add combobox control tests
ynotdraw Jul 6, 2023
e7e1b15
tests: Add combobox field tests
ynotdraw Jul 6, 2023
5916adc
tests: Add ToucanForm Combobox tests
ynotdraw Jul 7, 2023
bcf716e
tests: Remove eslint-disable no-undef
ynotdraw Jul 7, 2023
74ab854
deps: Add pnpm-lock changes
ynotdraw Jul 7, 2023
30d87e8
fix: Add explicit on modifier import
ynotdraw Jul 7, 2023
91204aa
Add a changeset entry
ynotdraw Jul 7, 2023
818905f
toucan-core:Add isDisabled arg to label+hint
ynotdraw Jul 7, 2023
b638b7d
Adjust glint typing
ynotdraw Jul 7, 2023
3ca35bb
Attempt to fix embroider error
ynotdraw Jul 7, 2023
975ba63
design: Remove bg-selected from selected option
ynotdraw Jul 7, 2023
40da407
toucan-core: Fix combobox reselection bug
ynotdraw Jul 7, 2023
bb353bb
toucan-core: Add JSDoc for option
ynotdraw Jul 7, 2023
f65648c
embroider: Remove compat from toucan-core
ynotdraw Jul 10, 2023
a4c0e54
Attempt to fix CI
ynotdraw Jul 10, 2023
40d0f0f
Revert "Attempt to fix CI"
ynotdraw Jul 10, 2023
abbc22a
Implemented suggestions
ynotdraw Jul 11, 2023
1111e1b
Temporarily disable embroider-optimized tests
ynotdraw Jul 11, 2023
edc9a6a
test: Add a test about reselection
ynotdraw Jul 11, 2023
40a9bb7
fix: Remove z-popover class
ynotdraw Jul 12, 2023
760601b
ci: Let embroider tests still run but not fail build?
ynotdraw Jul 13, 2023
ccac800
Revert "ci: Let embroider tests still run but not fail build?"
ynotdraw Jul 13, 2023
1b39ff1
Update docs/components/combobox/index.md
ynotdraw Jul 14, 2023
4f2d139
Use an assert instead of a comment
ynotdraw Jul 14, 2023
45594a7
Remove outdated JSdoc
ynotdraw Jul 14, 2023
e40c4e1
Adjust optionKey to use OPTION
ynotdraw Jul 14, 2023
754b29b
Remove @babel/plugin-proposal-class-properties
ynotdraw Jul 14, 2023
0c8f958
Uncomment ember-try config
ynotdraw Jul 14, 2023
ac3991c
fix typos in tests
ynotdraw Jul 14, 2023
d036a43
Remove unnecessary await
ynotdraw Jul 14, 2023
2b74de0
Add docs around onFilter
ynotdraw Jul 14, 2023
bbb761e
Remove ember-velcro dep in docs/test apps
ynotdraw Jul 14, 2023
3d4431c
Revert "Remove ember-velcro dep in docs/test apps"
ynotdraw Jul 14, 2023
212cd77
Remove unused internal selected getter
ynotdraw Jul 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .changeset/twelve-gifts-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
'@crowdstrike/ember-toucan-core': patch
'@crowdstrike/ember-toucan-form': patch
---

Added a `Combobox` component to both core and form packages.

If you're using `toucan-core`, the control and field components are exposed:

```hbs
<Form::Controls::Combobox
@onChange={{this.onChange}}
@options={{this.options}}
@contentClass='z-10'
@selected={{this.selected}}
@optionKey='label'
@noResultsText='No results'
placeholder='Colors'
as |combobox|
>
<combobox.Option>
{{combobox.option.label}}
</combobox.Option>
</Form::Controls::Combobox>

<Form::Fields::Combobox
@contentClass='z-10'
@error={{this.errorMessage}}
@hint='Type "blue" into the field'
@label='Label'
@noResultsText='No results'
@onChange={{this.onChange}}
@optionKey='label'
@options={{this.options}}
@selected={{this.selected}}
placeholder='Colors'
as |combobox|
>
<combobox.Option>
{{combobox.option.label}}
</combobox.Option>
</Form::Fields::Combobox>
```

If you're using `toucan-form`, the component is exposed via:

```hbs
<ToucanForm as |form|>
<form.Combobox
@label='Combobox'
@name='combobox'
@options={{options}}
data-combobox
as |combobox|
>
<combobox.Option data-option>{{combobox.option}}</combobox.Option>
</form.Combobox>
</ToucanForm>
```

For more information on using these components, view [the docs](https://ember-toucan-core.pages.dev/docs/components/combobox).
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ jobs:
- ember-release
- ember-beta
- ember-canary
- "'ember-release + embroider-optimized'"
- "'ember-lts-4.8 + embroider-optimized'"
# @todo Temporarily disabling embroider optimized tests due to https://github.com/CrowdStrike/ember-toucan-core/issues/210
# - "'ember-release + embroider-optimized'"
# - "'ember-lts-4.8 + embroider-optimized'"

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions docs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
"ember-browser-services": "^4.0.4",
"ember-modifier": "^4.1.0",
"ember-resources": "^6.0.0",
"ember-velcro": "^2.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

So much work to get to this stage of being able to import ember-velcro

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to add it here? The addon already has it as a dependency. so that should be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, unfortunately without it we get the following error on a build: https://github.com/CrowdStrike/ember-toucan-core/actions/runs/5554403233/jobs/10144183085?pr=200

docs-app:build:   - originalErrorMessage: Module not found: Error: Can't resolve '../../../node_modules/.pnpm/[email protected]_@[email protected][email protected]/node_modules/ember-velcro/components/velcro/index' in '$TMPDIR/embroider/e83321/docs-app/components/velcro/index.js'

😭

"highlight.js": "^11.6.0",
"highlightjs-glimmer": "^2.0.0",
"tracked-built-ins": "^3.1.0"
Expand Down
74 changes: 74 additions & 0 deletions docs/components/combobox-field/demo/base-demo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
```hbs template
<Form::Fields::Combobox
@contentClass='z-10'
@error={{this.errorMessage}}
@hint='Type "blue" into the field'
@label='Label'
@noResultsText='No results'
@onChange={{this.onChange}}
@optionKey='label'
@options={{this.options}}
@selected={{this.selected}}
placeholder='Colors'
as |combobox|
>
<combobox.Option>
{{combobox.option.label}}
</combobox.Option>
</Form::Fields::Combobox>
```

```js component
import Component from '@glimmer/component';
import { action } from '@ember/object';
import { tracked } from '@glimmer/tracking';

export default class extends Component {
@tracked selected;
@tracked errorMessage;

options = [
{
label: 'Blue',
name: 'blue',
},
{
label: 'Green',
name: 'green',
},
{
label: 'Yellow',
name: 'yellow',
},
{
label: 'Orange',
name: 'orange',
},
{
label: 'Red',
name: 'red',
},
{
label: 'Purple',
name: 'purple',
},
{
label: 'Teal',
name: 'teal',
},
];

@action
onChange(option) {
this.selected = option;
console.log(option);

if (option.label !== 'Blue') {
this.errorMessage = 'Please select "Blue"';
return;
}

this.errorMessage = null;
}
}
```
Loading