-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ComboBox.Input add additional API props #1256
Comments
Hey! Thank you for your bug report! This should be fixed by #1265, and will be available in the next release. The PR allows you to write your own event handlers like You can already try it using |
That is awesome @RobinMalfait thank you for the speedy response! Going to try it out. |
@saulflores95 Are you able to customise the onClick to trigger addOnClick when you press enter for a combobox option with the tag doesn't exist? My code looks something like this <Combobox.Options className={'absolute top-10 bg-white rounded-md overflow-y-auto'}>
{filteredOptions.map(option => (
<Combobox.Option key={option} value={option}>
{({ active, selected }) => (
<div className={`${active ? 'bg-slate-300 p-2' : ''} p-2`}>
{option}
</div>
)}
</Combobox.Option>
))}
{filteredOptions.length === 0 &&
<Combobox.Option as="button" key={query} value={query} className={'text-gray-800 p-2'} onClick={() => {
options.push(query)
console.log("create onclick: ", query)
setSelected(query)
}}
>
{({ active, selected }) => (
<div className={`${active ? 'bg-slate-300 p-2 rounded-md' : ''} p-2`}>
Create <span className="font-bold">{query}</span>
</div>
)}
</Combobox.Option>
}
</Combobox.Options> |
Discussed in #1255
Originally posted by saulflores95 March 18, 2022
What package within Headless UI are you using?
@headlessui/react
What version of that package are you using?
v1.5.0
What browser are you using?
Chrome
Currently using headless UI Combo Box we are using it to be able to select existing 'tags' and if a tag does not exist we create it by clicking on an icon that was added. This onClick event triggers a method called addOnClick.
The functionality we want is to detect when the 'Enter is pressed I want to trigger the same addOnClick Method.
The component looks as such.
Currently, it is not shown in the docs if it's possible to expand the current onKeyDown functionality that headless UI already provides.
By taking a look at headless UI we can see there is an interface that defines the two possible props to pass down
and a type where we can see the onKeyDown event being an option.
Is there any possible way of augmenting/expanding the keyDown prop? For example, just wanting to trigger the addOnClick method when a key down event is detected an enter key being pressed?
For example
The text was updated successfully, but these errors were encountered: