Unable to set default value to the AutoCompleteInput
See original GitHub issue
let cats = [
{ id: 'CAT_1', label: 'Kitty 1' },
{ id: 'CAT_2', label: 'Kitty 2'},
];
return
<AutoComplete openOnFocus suggestWhenEmpty rollNavigation>
<AutoCompleteInput variant="ghost" bgColor="transparent" />
<AutoCompleteList fontStyle="normal">
{cats.map((cat) => (
<AutoCompleteItem
key={cat.id}
value={cat.label}
textTransform="capitalize"
>
{cat.label}
</AutoCompleteItem>
))}
</AutoCompleteList>
</AutoComplete>
}
Package version “@choc-ui/chakra-autocomplete”: “^4.3.3”,
I want the default value in the input box to be set to “Kitty 1” whenever the page loads. With the above code, the input box is empty on page load which seems like the expected behaviour.
- I tried setting defaultValue to the
<AutoCompleteInput>
component but it doesn’t do anything. - I tried setting value to the <AutoCompleteInput> component. It worked but whenever I focus on the input box first time and click outside the
<AutoCompleteList>
, the value disappears.
What is the right way to go about it?
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Autocomplete - How can I set a default value? - Stack Overflow
The component have a dataSource , and I'd like to load the page with a specific item already selected(e.g. fill the text field...
Read more >enableGetChoices prevents setting defaultValue on ... - GitHub
What you were expecting: For a AutocompleteInput with a ReferenceInput as a parent to receive the prop "defaultValues" and make the required ...
Read more >How to turn off form autocompletion - Web security | MDN
This article explains how a website can disable autocomplete for form fields. By default, browsers remember information that the user ...
Read more >How to set default value with next line in NowMobile input ...
i've tried using \n, <br>, and br(). It seems not able to format it. Please see the screen shot in the attachments. In...
Read more >How to Use The Autocomplete Component in Material-UI
Set up; Render the Autocomplete component; Props; Handle the value; Additional props; Conclusion ... We will set the default value to null.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yeah…that would work, but I should handle it internally. I’ll work on this, in a moment
I’ll try this and get back. Thanks for the quick reply.