Comments (17)
@anilanar I think it's better to leave the latter part to developers. You might want it to be open when focused and want it to close once selected. And in your usecase, there's no way you want it to be focused and close.
from zag.
Suggestion: An alternative combobox mode (or a separate machine) that behaves more like a menu with text filtering. The main difference is that combobox would be open as long as input is focused.
from zag.
Suggestion: An alternative combobox mode (or a separate machine) that behaves more like a menu with text filtering. The main difference is that combobox would be open as long as input is focused.
@anilanar Could you shed more context and give a use case. Example libraries will be most helpful
from zag.
@anilanar Isn't this what you're looking for?
from zag.
That isn't sufficient, because it doesn't open on focus, only opens on click.
from zag.
The use case is select/multi-select combobox where
- user potentially doesn't have enough knowledge to input text without seeing combobox options. for example, github labels.
- there are too many options, thus requiring text filtering.
Due to Point 2, cannot use a select/multiselect component (one that lacks an input field for filtering) for that use case, must use a combobox.
Due to Point 1, should probably keep combobox open as long as input is focused.
In addition, with multi-selection, it's sometimes more preferable to not close combobox on select.
from zag.
@anilanar The way I see it a openOnFocus
and closeOnSelect
prop should be okay right?
from zag.
Yes, but it's harder to then imagine if there exists any state that is focused
but not open
.
It would be simpler to introduce a mode that makes isOpen = isFocused
.
But with 2 props to control like that, then can potentially have more flexibility/freedom.
from zag.
Bug report:
Reproduction:
- In next-ts example project, click on toggle button.
- Immediately hit TAB.
It crashes with:
TypeError: ctx2.selectionData is null
In selectOption
action, the following line fails because it assumes (with the !
operator) that there's a selection when there's none:
if (ctx.selectionBehavior === "set") {
value = ctx.selectionData!.label
}
from zag.
Bug or not?
Reproduction:
- Set
selectOnTab: false
- Click toggle button
- Hit arrow down couple times to highlight an option.
- Hit tab
Outcome: State stays in interacting
(so it thinks it still has focus), focuses listbox element.
Expected: State switches to idle
, focuses the next element in page.
from zag.
Bug or not?
Reproduction:
- Set
selectOnTab: false
- Click toggle button
- Hit arrow down couple times to highlight an option.
- Hit tab
Outcome: State stays in
interacting
(so it thinks it still has focus), focuses listbox element. Expected: State switches toidle
, focuses the next element in page.
@anilanar It's a bug, please open an issue.
from zag.
Potential problem:
After closeOnSelect: false
is implemented, implementing a multi-select combobox doesn't feel natural because the last selection is stored in context.selectionData
and onSelect
is triggered with a watch on that. So selecting the same option (via ENTER) doesn't trigger an onSelect
because context.selectionData
doesn't change, so toggling an option forth and back doesn't work.
Reproduction:
- Set
closeOnSelect: false
andselectionBehavior: clear
. - Add an
onSelect
callback andconsole.log('onSelect')
. - Click toggle button, hit arrow down key couple times and highlight an option.
- Hit ENTER key. You'll see something in log.
- Now hit ENTER as many times as you want.
Output: Nothing is logged.
Expected: Each ENTER logs onSelect
.
from zag.
Another case of double emitting click events similar to #237:
When closeOnSelect: false
is implemented, option click events are emitted twice, breaking the use case of toggleable options. It's due to onPointerUp
event handler, which manually triggers an additional click
event.
Reproduction:
- Set
closeOnSelect: false
. - Add an
onSelect
callback andconsole.log('onSelect')
. - Click toggle button to open the combobox.
- Click an option.
Output: onSelect
is logged twice.
Expected: onSelect
is logged once.
from zag.
Hi @anilanar, It'll be helpful if you also attach a minimal reproduction for these issues. or at least a screen recording that captures the bug.
from zag.
I implemented closeOnSelect: false
myself, so there's no reproduction on existing code yet. I edited above posts and added reproductions anyways.
from zag.
I implemented
closeOnSelect: false
myself, so there's no reproduction on existing code yet. I edited above posts and added reproductions anyways.
Hi @anilanar would be nice for you to open a different issue, to track your specific case.
from zag.
I'll open separate issues and PRs for this task
from zag.
Related Issues (20)
- Combobox example for SolidJS is broken (render is different from state)
- Add support for the WAI-ARIA grid pattern
- Add `onEscapeKeydown` handlers to menus HOT 4
- String literal types in `select` machine values
- Popper elements: Cross-axis in `placement` serves no purpose HOT 1
- Tags Input: Pasting text on `TagsInput` breaks functionality HOT 2
- [CircularProgress Indeterminate state] when value: null, it throws errors HOT 1
- Replace `klona/full` to solve the "Maximum call stack size exceeded" issue in Vue 2.7 HOT 4
- [Circular progress] circle diameter is not correct with --size variable HOT 2
- Select: hidden select is being set to disabled when readOnly attribute is set HOT 1
- No Documentation for the Presence component
- [Number Input] Issue - SolidJS max breaks when setting value to max HOT 3
- `data-acitve` is not deactivated if the mouse button is released on outside of its element HOT 2
- Bug: Accordion / Collapsible - Items animate on initial render / flicker in page reload
- [Combobox] Focus input on mount HOT 2
- multi-selectable Select and Combobox value is unintentionally sorted when opening the listbox
- No 'Visualize Logic' for Presence
- MenuItem is not processable with enter key when not Link element HOT 3
- [React][Carousel] Next / Prev triggers not respecting slidesPerView with loop HOT 3
- [Vue][popover] Don't work on Nuxt and portalled is set to true by default HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zag.