ui icon indicating copy to clipboard operation
ui copied to clipboard

[bug]: Select not focus input

Open namnotfake opened this issue 1 year ago • 1 comments

Describe the bug

When selecting an element of a select that is associated with the focus input action, the input does not get focus but focuses on that select

Affected component/components

Select, Input

How to reproduce

1: Create select 2: Create Input 3: Attach events related to focus input when change value select

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

Browers

Before submitting

  • [X] I've made research efforts and searched the documentation
  • [X] I've searched for existing issues

namnotfake avatar Apr 10 '24 02:04 namnotfake

same here

blue86321 avatar Sep 30 '24 10:09 blue86321

Could you share the code you are using to focus the input when the select value changes? Introducing a short delay resolved this issue for me.

  const handleSelectChange = (value: string) => {
	...
    setTimeout(() => {
      inputRef.current?.focus();
    }, 100); // Small delay to ensure the DOM is updated

    ...
  };

rahulbarwal avatar Jul 25 '25 06:07 rahulbarwal

Hi. We're closing some old issues as outdated. If this is still relevant, leave a message, we'll reopen it. Thank you. Appreciate your contribution to the project - shadcn

shadcn avatar Oct 06 '25 13:10 shadcn