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

Input输入框 onInput事件触发setData后,会自动收起键盘,导致无法持续输入 #15996

Closed
tianguzhe opened this issue Jun 28, 2024 · 0 comments

Comments

@tianguzhe
Copy link

相关平台

微信小程序

小程序基础库: 3.4.7
使用框架: React

复现步骤

import { useState } from "react";
import { Input, View } from "@tarojs/components";

const TestPage = () => {
  const [inputValue, setInputValue] = useState("");

  const handleInput = (e) => {
    setInputValue(e.detail.value);
  };

  const SearchBar = () => {
    return (
      <Input
        type="text"
        value={inputValue}
        onInput={handleInput}
        placeholder="请输入"
        focus={true} // 确保 Input 组件在初始化时获取焦点
      />
    );
  };

  return (
    <View>
      <View
        style={{
          height: 100,
        }}
      />
      <SearchBar />
    </View>
  );
};

export default TestPage;

期望结果

能够持续输入

实际结果

输入一个字符,setInputValue后,键盘自动收起导致无法持续输入

环境信息

 Taro CLI 3.6.32 environment info:
    System:
      OS: macOS 14.5
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 22.3.0 - /opt/homebrew/bin/node
      Yarn: 1.22.22 - /opt/homebrew/bin/yarn
      npm: 10.8.1 - /opt/homebrew/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.32 => 3.6.32
      @tarojs/components: 3.6.32 => 3.6.32
      @tarojs/helper: 3.6.32 => 3.6.32
      @tarojs/plugin-framework-react: 3.6.32 => 3.6.32
      @tarojs/plugin-platform-alipay: 3.6.32 => 3.6.32
      @tarojs/plugin-platform-h5: 3.6.32 => 3.6.32
      @tarojs/plugin-platform-jd: 3.6.32 => 3.6.32
      @tarojs/plugin-platform-qq: 3.6.32 => 3.6.32
      @tarojs/plugin-platform-swan: 3.6.32 => 3.6.32
      @tarojs/plugin-platform-tt: 3.6.32 => 3.6.32
      @tarojs/plugin-platform-weapp: 3.6.32 => 3.6.32
      @tarojs/react: 3.6.32 => 3.6.32
      @tarojs/runtime: 3.6.32 => 3.6.32
      @tarojs/shared: 3.6.32 => 3.6.32
      @tarojs/taro: 3.6.32 => 3.6.32
      @tarojs/taro-loader: 3.6.32 => 3.6.32
      @tarojs/webpack5-runner: 3.6.32 => 3.6.32
      babel-preset-taro: 3.6.32 => 3.6.32
      eslint-config-taro: 3.6.32 => 3.6.32
      react: ^18.0.0 => 18.3.1
This was referenced Jun 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant