Skip to content
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

[material-ui][Autocomplete] Selected Option is hidden when it is Focused #42173

Closed
SunilKumar33 opened this issue May 9, 2024 · 5 comments
Closed
Assignees
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material support: Stack Overflow Please ask the community on Stack Overflow

Comments

@SunilKumar33
Copy link

SunilKumar33 commented May 9, 2024

Steps to reproduce

Link to live example: https://stackblitz.com/edit/react-j8inhi?file=index.tsx

Steps:

  1. Select any long option from the options list(eg: The Lord of the Rings: The Fellowship of the Ring).
  2. After Selecting the option, click outside of the AutoComplete component.
  3. Again revisit the AutoComplete component by clicking on arrow icon or inside the textfield, Then it will be Focused. Only for
    the first time we can see that the initial text is hidden but if we try to open again the initial text is visible.

Current behavior

For the First Time I am getting issue has in screenshot:
autocomplete issue

Expected behavior

autocomplete excepted

Context

When any long option is selected and when it is focused the selected option should be visible from start of the option not from the end.

Your environment

npx @mui/envinfo
  Don't forget to mention which browser you used.
  Output from `npx @mui/envinfo` goes here.

Search keywords: I have searched the existing issues

@SunilKumar33 SunilKumar33 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 9, 2024
@zannager zannager added the component: autocomplete This is the name of the generic UI component, not the React module! label May 9, 2024
@brijeshb42
Copy link
Contributor

Do you mean that the selected option should appear at the top when you re-open the autocomplete dropdown?
What you are seeing is the expected behaviour right now where the list is opened with the selected value being auto focussed.

@brijeshb42 brijeshb42 added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 10, 2024
@yassinmars
Copy link

To address the visibility issue of the selected option in the AutoComplete component upon focus, I propose a direct adjustment to the component's handling of input focus to ensure the text starts from the beginning. I've tested this solution in the provided StackBlitz example, modifying the component's input handling to reset the scroll position on focus. This approach consistently shows the full selected text without cutting off the start, enhancing usability and ensuring the content is fully visible upon re-entry. Here's a code snippet that might be included:

image

This method ensures the selected text is always visible from the start, potentially resolving the issue without needing additional modifications or workarounds.

@SunilKumar33
Copy link
Author

@yassinmars The suggested method works. Thank You for the info.

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels May 15, 2024
@mj12albert mj12albert added the package: material-ui Specific to @mui/material label May 15, 2024
@mj12albert mj12albert changed the title AutoComplete Selected Option is hidden when it is Focused [material-ui][Autocomplete] Selected Option is hidden when it is Focused May 15, 2024
@mj12albert mj12albert added support: Stack Overflow Please ask the community on Stack Overflow and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels May 15, 2024
Copy link

👋 Thanks for using our open-source projects!

We use GitHub issues exclusively as a bug and feature requests tracker, however,
this issue appears to be a support request.

For support with Material UI please check out https://mui.com/material-ui/getting-started/support/. Thanks!

If you have a question on Stack Overflow, you are welcome to link to it here, it might help others.
If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 15, 2024
@mj12albert
Copy link
Member

Thanks @yassinmars for looking into this 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: autocomplete This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material support: Stack Overflow Please ask the community on Stack Overflow
Projects
None yet
Development

No branches or pull requests

5 participants