Skip to content

How to blur the select after a clear is executed? #5964

Answered by manjushsh
Rafael-Ramblas asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Rafael-Ramblas, hope this comment by @ebonow helps: #1309 (comment).

Codesandbox Link:

Code Sandbox

Screenshot:

Code:

import { useRef, useState } from "react";
import Select, {
  SelectInstance,
  OnChangeValue,
  ActionMeta,
} from "react-select";
import "./styles.css";

interface ColorOption {
  value: string;
  label: string;
}

const colorOptions: ColorOption[] = [
  { value: "red", label: "Red" },
  { value: "green", label: "Green" },
  { value: "blue", label: "Blue" },
];

const SelectComponent: React.FC = () => {
  const [value, setValue] = useState();
  const selectRef = useRef<SelectInstance<ColorOption> | null>(null);
  function onClear() {
    setTimeout(() => selectRef?.c…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by Rafael-Ramblas
Comment options

You must be logged in to vote
1 reply
@manjushsh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants