mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(NumberKeyboard): show-delete-key prop not work (#5935)
This commit is contained in:
parent
cd07773e34
commit
ac3c77c17f
@ -145,7 +145,7 @@ Use `title` prop to set keyboard title
|
||||
| extra-key | Content of bottom left key | *string* | `''` |
|
||||
| close-button-text | Close button text | *string* | `-` |
|
||||
| delete-button-text | Delete button text | *string* | `delete` |
|
||||
| show-delete-key | Whether to show delete button | *boolean* | `true` |
|
||||
| show-delete-key `v2.6.0` | Whether to show delete button | *boolean* | `true` |
|
||||
| hide-on-click-outside | Whether to hide keyboard when click outside | *boolean* | `true` |
|
||||
| safe-area-inset-bottom | Whether to enable bottom safe area adaptation | *boolean* | `true` |
|
||||
|
||||
|
@ -151,7 +151,7 @@ export default {
|
||||
| extra-key | 左下角按键内容 | *string* | `''` |
|
||||
| close-button-text | 关闭按钮文字,空则不展示 | *string* | `-` |
|
||||
| delete-button-text | 删除按钮文字 | *string* | `删除` |
|
||||
| show-delete-key | 是否展示删除按钮 | *boolean* | `true` |
|
||||
| show-delete-key `v2.6.0` | 是否展示删除按钮 | *boolean* | `true` |
|
||||
| hide-on-click-outside | 点击外部时是否收起键盘 | *boolean* | `true` |
|
||||
| safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | *boolean* | `true` |
|
||||
|
||||
|
@ -137,6 +137,8 @@ export default {
|
||||
@import '../../style/var';
|
||||
|
||||
.demo-number-keyboard {
|
||||
padding-bottom: 300px;
|
||||
|
||||
.van-button {
|
||||
margin-left: @padding-md;
|
||||
}
|
||||
|
@ -81,7 +81,11 @@ export default createComponent({
|
||||
keys.push(
|
||||
{ text: this.extraKey, theme: ['gray'], type: 'extra' },
|
||||
{ text: 0 },
|
||||
{ text: this.deleteText, theme: ['gray'], type: 'delete' }
|
||||
{
|
||||
theme: ['gray'],
|
||||
text: this.showDeleteKey ? this.deleteText : '',
|
||||
type: this.showDeleteKey ? 'delete' : '',
|
||||
}
|
||||
);
|
||||
break;
|
||||
case 'custom':
|
||||
@ -179,14 +183,16 @@ export default createComponent({
|
||||
if (this.theme === 'custom') {
|
||||
return (
|
||||
<div class={bem('sidebar')}>
|
||||
<Key
|
||||
text={this.deleteText}
|
||||
type="delete"
|
||||
theme={DELETE_KEY_THEME}
|
||||
onPress={this.onPress}
|
||||
>
|
||||
{this.slots('delete')}
|
||||
</Key>
|
||||
{this.showDeleteKey && (
|
||||
<Key
|
||||
text={this.deleteText}
|
||||
type="delete"
|
||||
theme={DELETE_KEY_THEME}
|
||||
onPress={this.onPress}
|
||||
>
|
||||
{this.slots('delete')}
|
||||
</Key>
|
||||
)}
|
||||
<Key
|
||||
text={this.closeButtonText}
|
||||
type="close"
|
||||
|
@ -46,6 +46,8 @@
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 25%;
|
||||
height: @number-keyboard-key-height * 4;
|
||||
}
|
||||
@ -82,9 +84,11 @@
|
||||
}
|
||||
|
||||
&--big {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
height: @number-keyboard-key-height * 2;
|
||||
line-height: @number-keyboard-key-height * 2;
|
||||
}
|
||||
|
||||
&--blue,
|
||||
|
@ -189,3 +189,25 @@ test('maxlength', () => {
|
||||
expect(wrapper.vm.value).toEqual('1');
|
||||
expect(onInput).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('show-delete-key prop', () => {
|
||||
const wrapper = mount(NumberKeyboard, {
|
||||
propsData: {
|
||||
showDeleteKey: true,
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.contains('.van-key--delete')).toBeTruthy();
|
||||
|
||||
wrapper.setData({ showDeleteKey: false });
|
||||
expect(wrapper.contains('.van-key--delete')).toBeFalsy();
|
||||
|
||||
wrapper.setData({
|
||||
theme: 'custom',
|
||||
showDeleteKey: true,
|
||||
});
|
||||
expect(wrapper.contains('.van-key--delete')).toBeTruthy();
|
||||
|
||||
wrapper.setData({ showDeleteKey: false });
|
||||
expect(wrapper.contains('.van-key--delete')).toBeFalsy();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user