Skip to content

Commit

Permalink
Merge pull request #1634 from axetroy/search-bar
Browse files Browse the repository at this point in the history
feat: AtSearchBar 增加 enableNative 参数
  • Loading branch information
robinv8 authored Jul 24, 2023
2 parents 00a2e4d + 09863bd commit 71684a4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/taro-ui-docs/markdown/search-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export default class Index extends Taro.Component {
| showActionButton ||| 是否一直显示右侧按钮 | Boolean | - | false |
| actionName ||| 右侧按钮文案 | String | - | '搜索' |
| inputType ||| 输入框输入类型 | String | 'text', 'number', 'idcard', 'digit' | 'text' |
| enableNative | | | 是否使用原生键盘,仅支持支付宝小程序 | Boolean | true |

## 事件

Expand Down
10 changes: 7 additions & 3 deletions packages/taro-ui/src/components/search-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export default class AtSearchBar extends React.Component<
actionName = '搜索',
inputType, // 处理issue#464
className,
customStyle
customStyle,
enableNative
} = this.props
const { isFocus } = this.state
const fontSize = 14
Expand Down Expand Up @@ -135,6 +136,7 @@ export default class AtSearchBar extends React.Component<
focus={isFocus}
disabled={disabled}
maxlength={maxLength}
enableNative={enableNative}
onInput={this.handleChange}
onFocus={this.handleFocus}
onBlur={this.handleBlur}
Expand Down Expand Up @@ -171,7 +173,8 @@ AtSearchBar.defaultProps = {
actionName: '搜索',
inputType: 'text',
// eslint-disable-next-line @typescript-eslint/no-empty-function
onChange: (): void => {}
onChange: (): void => {},
enableNative: true
}

AtSearchBar.propTypes = {
Expand All @@ -189,5 +192,6 @@ AtSearchBar.propTypes = {
onBlur: PropTypes.func,
onConfirm: PropTypes.func,
onActionClick: PropTypes.func,
onClear: PropTypes.func
onClear: PropTypes.func,
enableNative: PropTypes.bool
}
5 changes: 5 additions & 0 deletions packages/taro-ui/types/search-bar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export interface AtSearchBarProps extends AtComponent {
* @default 'text'
*/
inputType?: 'text' | 'number' | 'idcard' | 'digit'
/** 使用原生键盘
* @default true
* @supported alipay
*/
enableNative?: boolean
/**
* 输入框值改变时触发的事件
* @description 必填,开发者需要通过 onChange 事件来更新 value 值变化
Expand Down

0 comments on commit 71684a4

Please sign in to comment.