You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

react-select组件设置contentEditable后无法编辑选中值的问题求助

react-select组件设置contentEditable后无法编辑选中值的问题求助

各位大佬好,我碰到个react-select的棘手问题:我没办法点击选择器并编辑选中值的文本。我敢肯定这不是我React项目里其他配置的问题,因为其他元素都能正常编辑,唯独这个react-select组件出状况。

下面是我的组件代码:

function EditableSelect() {
  const [selectedOption, setSelectedOption] = useState(null);

  const options = [
    { label: "Editable Options", value: 1 },
    { label: "Black Magic", value: 2 },
    { label: "Very Possible ", value: 3 }
  ];

  const onInputChange = (newValue, action) => {
    console.log("new value", newValue);
    console.log("action", action);
  };

  return (
    <>
      <Select
        defaultValue={selectedOption}
        onChange={setSelectedOption}
        isSearchable={true}
        options={options}
        contentEditable={true}
        onInputChange={onInputChange}
      />
    </>
  );
}

我已经在StackOverflow和GitHub上搜了一圈react-select相关的问题,愣是没找到类似的情况和对应的解决方案,有没有懂行的朋友帮忙指点下?

备注:内容来源于stack exchange,提问作者pls-help-me

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 10:58:16