Tab selection and shouldSelect not working when Input is not first child of Hint Component
See original GitHub issueVersion
5.1.4
Steps to reproduce
Have a custom input with a label in renderInput method
<Typeahead
id={id}
labelKey={labelKey}
options={options}
minLength={minLength}
highlightOnlyResult={highlightOnlyResult}
className={className}
emptyLabel={emptyLabel}
inputProps={{ 'aria-autocomplete': 'list', className: 'form-control', required }}
onChange={(data) => onChange(data?.[0]?.[optionsValue])}
inputRef={ref}
defaultInputValue={defaultInputValue}
renderInput={({ inputRef, referenceElementRef, ...inputProps }) => (
<Hint shouldSelect={(shouldSelect, e) => e.keyCode === 9 || shouldSelect }>
<>
<InputTypeahead
id={id}
{...inputProps}
ref={(input) => {
inputRef(input);
referenceElementRef(input);
}}
/>
<label className="form-control-placeholder" htmlFor={id}>
<span>{placeholder}</span>
</label>
</>
</Hint>
)}
{...props}
/>
Expected Behavior
Item being selected when Tab key is pressed
Actual Behavior
Tab key actually moves to next item in DOM, without selecting any option
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Why is my first-child selector not working on the first element in ...
:first-child matches the first child of its parent. Your first a.trigger is not the first child — that would be the classless a...
Read more >first-of-type - CSS: Cascading Style Sheets - MDN Web Docs
The :first-of-type CSS pseudo-class represents the first element of its type among a group of sibling elements.
Read more >Advanced Marketplace Issues and Technical Support
This course provides training on how to help consumers in individual market FFMs with more complex eligibility and enrollment issues not previously covered...
Read more >RAPIDS 7.3 User Guide - SSI LRC
customer may assume their CAC is not working. Their systems administrators can install the latest DISA root certificates if this occurs.
Read more >Pipeline: Input Step - Jenkins
This step pauses Pipeline execution and allows the user to interact and control the flow of the build. Only a basic "proceed" or...
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
Hey @daniel-carrillo-globant, thanks for the question.
Hint
expects a single child, and for that child to either be your input or to correctly handle the keydown handler it adds. You could try taking the current children and making them a component to do that:@ericgio Thank you for your really fast reply! I’ve actually just found a workaround in here, I used the useHint hook and created this component with the label in it:
And inside the renderInput method I’ve just called it this way:
However, your response seems to be also accurate, I’ll try that one as well. Thank you very much!