Description
Steps to reproduce
Steps:
- Open this link to live example: https://codesandbox.io/p/sandbox/quizzical-dewdney-wv3jzg
- Search for the term
pediatric
- notice how the autohighlight is NOT on the first dropdown item. However, if we press enter, we will still correctly select the first dropdown item (pediatrician
) - Delete the last letter
c
so that we have the termpediatri
- notice how the autohighlight is now onpediatrician
, the third term. If we press enter, we correctly select the first dropdown item,pediatric ent
.
Current behavior
autohighlight styling is not always on the first dropdown item if the previous first row item is on the most recent batch of dropdown options and is in a different row/order. See steps to recreate this behavior.
CleanShot.2025-02-10.at.12.48.38.mp4
Expected behavior
autohighlight styling should always initially be on the first dropdown item
Context
I am using MUI's autocomplete for a specific use case. I do not filter down the results the more you type. Instead, I might return different results, or the same results but in a different order.
In this example, I simulate the bug that I am seeing in my application. You will notice that the autohighlight attribute does not work properly when the next batch of options contains the previous first row's option; we highlight the previous first dropdown item when we should highlight the new first option. However, if the user presses Enter
, the component still correctly selects the first row (assuming the user hasn't manually highlighted some other row).
Is there a fix for this, or a workaround I am missing? I have searched past issues and it seems like something similar has come up (but no potential fixes).
Your environment
I am using version 5 (see package.json).
Search keywords: Autocomplete, autohighlight