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 希望支持 focus blur clear is Focused 方法 #10813

Open
zhiqingchen opened this issue Dec 3, 2021 · 3 comments
Open

Input 希望支持 focus blur clear is Focused 方法 #10813

zhiqingchen opened this issue Dec 3, 2021 · 3 comments
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x

Comments

@zhiqingchen
Copy link
Member

相关平台

React Native

image

使用框架: React

复现步骤

Taro-rn 的 Input组件的focus属性有点歧义啊,Input组件封装的是rn的TextInput, TextInput的autoFocus只是在componentDidMount or useEffect时起作用。所以Input组件的focus也只是在mount的时候起作用,之后改变focus的state并不会起到focus的作用,要focus到一个input需要实现TextInput的focus()方法。

期望结果

不支持 focus blur clear is Focused 方法

实际结果

支持 focus blur clear is Focused 方法

环境信息

👽 Taro v3.3.15


  Taro CLI 3.3.15 environment info:
    System:
      OS: macOS 12.0.1
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 15.12.0 - /usr/local/bin/node
      Yarn: 1.22.10 - ~/.nvm/versions/node/v15.12.0/bin/yarn
      npm: 7.6.3 - ~/.nvm/versions/node/v15.12.0/bin/npm
    npmPackages:
      @tarojs/cli: 3.3.15 => 3.3.15
      @tarojs/components: 3.3.15 => 3.3.15
      @tarojs/mini-runner: 3.3.15 => 3.3.15
      @tarojs/react: 3.3.15 => 3.3.15
      @tarojs/runtime: 3.3.15 => 3.3.15
      @tarojs/taro: 3.3.15 => 3.3.15
      @tarojs/webpack-runner: 3.3.15 => 3.3.15
      babel-preset-taro: 3.3.15 => 3.3.15
      eslint-config-taro: 3.3.15 => 3.3.15
      react: ^17.0.2 => 17.0.2
      react-native: ^0.66.0 => 0.66.3
    npmGlobalPackages:
      typescript: 4.2.3
@taro-bot2 taro-bot2 bot added F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x labels Dec 3, 2021
@zhiqingchen
Copy link
Member Author

zhiqingchen commented Dec 3, 2021

todo:
使用 forwardedRef 包装相应组件。用户可以通过 ref 进行调用。

@shinken008
Copy link
Collaborator

shinken008 commented Sep 9, 2022

clear 可以不用到,受控时直接设置值为空就行了,除非考虑不受控清空的场景。

focus blur:
autofocus 只有mount时生效,其他端的这个属性已经“(即将废弃,请直接使用 focus )自动聚焦,拉起键盘”,不建议使用,使用 focus 就行了。

isFocused 方法取内置状态,应该也用的不多,如果传 focus props 受控的话,外部也能同步 focus 状态,同 clear,所以 ref 话好像意义也不大。

@shinken008
Copy link
Collaborator

#12466

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-rn Target - 编译到 React Native V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants