Steps to reproduce
Steps:
- Open this link to live example: useAutocomplete highlight problem example.
- Follow the descriptions below for each issue.
- You may need to refresh the stackblitz inner iframe when the dependencies are loaded.
Current behavior
- when
multiple option is enabled:
- when
autoHighlight is disabled:
- when we use
value or defaultValue (have some options selected by default)
- Issue 1:
- focus the input.
- use the arrow down button.
Notice that the highlight starts below the last selected option.
- Issue 2:
- focus the input.
- press
Enter.
Notice that the last selected value is unselected.
- when
autoHighlight is enabled:
- when we use
value or defaultValue (have some options selected by default)
- focus the input
Notice that the highlighted option in the last selected option.
Expected behavior
- when
multiple option is enabled:
- when
autoHighlight is disabled:
- when we use
value or defaultValue (have some options selected by default)
- Issue 1:
- focus the input.
- use the arrow down button.
The highlight should start from the first option (index 0).
- Issue 2:
- focus the input.
- press
Enter.
Enter should do nothing (noop) because nothing should be highlighted in that moment.
- when
autoHighlight is enabled:
- when we use
value or defaultValue (have some options selected by default)
- focus the input
The highlighted should be the first option (index 0).
Context
I am trying to build a very complex component using useAutocomplete that is out of context of this issue. I am demonstrating the issue with the example of the useAutocomplete from mui documentation https://mui.com/material-ui/react-autocomplete/#customized-hook.
Your environment
npx @mui/envinfo
Don't forget to mention which browser you used.
Output from `npx @mui/envinfo` goes here.
Search keywords: useAutocomplete, autocomplete, highlight
Search keywords:
Steps to reproduce
Steps:
Current behavior
multipleoption is enabled:autoHighlightis disabled:valueordefaultValue(have some options selected by default)Notice that the highlight starts below the last selected option.
Enter.Notice that the last selected value is unselected.
autoHighlightis enabled:valueordefaultValue(have some options selected by default)Notice that the highlighted option in the last selected option.
Expected behavior
multipleoption is enabled:autoHighlightis disabled:valueordefaultValue(have some options selected by default)The highlight should start from the first option (index 0).
Enter.Enter should do nothing (noop) because nothing should be highlighted in that moment.
autoHighlightis enabled:valueordefaultValue(have some options selected by default)The highlighted should be the first option (index 0).
Context
I am trying to build a very complex component using useAutocomplete that is out of context of this issue. I am demonstrating the issue with the example of the useAutocomplete from mui documentation https://mui.com/material-ui/react-autocomplete/#customized-hook.
Your environment
npx @mui/envinfoSearch keywords: useAutocomplete, autocomplete, highlight
Search keywords: