Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ exports[`date-time-picker :base 1`] = `
class="t-picker__cancel t-class-cancel"
bind:tap="onCancel"
>
取消

取消

</wx-view>
<wx-view
class="t-picker__title t-class-title"
Expand All @@ -49,7 +51,9 @@ exports[`date-time-picker :base 1`] = `
class="t-picker__confirm t-class-confirm"
bind:tap="onConfirm"
>
确认

确定

</wx-view>
</wx-view>
<wx-view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ exports[`Picker Picker area demo works fine 1`] = `
bind:click="onAreaPicker"
/>
<t-picker
cancelBtn="取消"
confirmBtn="确认"
title="选择地区"
usingCustomNavbar="{{true}}"
value="{{Array []}}"
Expand Down Expand Up @@ -137,8 +135,6 @@ exports[`Picker Picker base demo works fine 1`] = `
bind:click="onSeasonPicker"
/>
<t-picker
cancelBtn="取消"
confirmBtn="确认"
data-key="city"
title="选择城市"
usingCustomNavbar="{{true}}"
Expand Down Expand Up @@ -203,8 +199,6 @@ exports[`Picker Picker base demo works fine 1`] = `
</t-picker-item>
</t-picker>
<t-picker
cancelBtn="取消"
confirmBtn="确认"
data-key="date"
title="选择时间"
usingCustomNavbar="{{true}}"
Expand Down Expand Up @@ -276,8 +270,6 @@ exports[`Picker Picker with-title demo works fine 1`] = `
bind:click="onWithoutTitlePicker"
/>
<t-picker
cancelBtn="取消"
confirmBtn="确认"
data-key="city"
title=""
usingCustomNavbar="{{true}}"
Expand Down Expand Up @@ -315,8 +307,6 @@ exports[`Picker Picker with-title demo works fine 1`] = `
/>
</t-picker>
<t-picker
cancelBtn="取消"
confirmBtn="确认"
data-key="city2"
title=""
usingCustomNavbar="{{true}}"
Expand Down Expand Up @@ -359,8 +349,6 @@ exports[`Picker Picker with-title demo works fine 1`] = `
exports[`Picker Picker without-popup demo works fine 1`] = `
<without-popup>
<t-picker
cancelBtn="取消"
confirmBtn="确认"
data-key="city"
title=""
usePopup="{{false}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ exports[`picker :base 1`] = `
class="t-picker__cancel t-class-cancel"
bind:tap="onCancel"
>
取消

取消

</wx-view>
<wx-view
class="t-picker__title t-class-title"
Expand All @@ -46,7 +48,9 @@ exports[`picker :base 1`] = `
class="t-picker__confirm t-class-confirm"
bind:tap="onConfirm"
>
确认

确认

</wx-view>
</wx-view>
<wx-view
Expand Down
82 changes: 82 additions & 0 deletions packages/components/picker/__test__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,88 @@ describe('picker', () => {
expect($city.toJSON()).toMatchSnapshot();
});

it(': cancelBtn false', async () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));

const $picker = comp.querySelector('#city');
comp.setData({ cityVisible: true });
$picker.instance.setData({ cancelBtn: false });
await simulate.sleep();

expect($picker.querySelector('.t-picker__cancel')).toBeUndefined();
expect($picker.querySelector('.t-picker__confirm')).toBeDefined();
});

it(': cancelBtn true', async () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));

const $picker = comp.querySelector('#city');
comp.setData({ cityVisible: true });
$picker.instance.setData({ cancelBtn: true });
await simulate.sleep();

const $cancel = $picker.querySelector('.t-picker__cancel');
expect($cancel).toBeDefined();
expect($cancel.dom.textContent.trim()).toBe('取消');
});

it(': cancelBtn custom text', async () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));

const $picker = comp.querySelector('#city');
comp.setData({ cityVisible: true });
$picker.instance.setData({ cancelBtn: '返回' });
await simulate.sleep();

const $cancel = $picker.querySelector('.t-picker__cancel');
expect($cancel).toBeDefined();
expect($cancel.dom.textContent.trim()).toBe('返回');
});

it(': confirmBtn false', async () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));

const $picker = comp.querySelector('#city');
comp.setData({ cityVisible: true });
$picker.instance.setData({ confirmBtn: false });
await simulate.sleep();

expect($picker.querySelector('.t-picker__cancel')).toBeDefined();
expect($picker.querySelector('.t-picker__confirm')).toBeUndefined();
});

it(': confirmBtn true', async () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));

const $picker = comp.querySelector('#city');
comp.setData({ cityVisible: true });
$picker.instance.setData({ confirmBtn: true });
await simulate.sleep();

const $confirm = $picker.querySelector('.t-picker__confirm');
expect($confirm).toBeDefined();
expect($confirm.dom.textContent.trim()).toBe('确认');
});

it(': confirmBtn custom text', async () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));

const $picker = comp.querySelector('#city');
comp.setData({ cityVisible: true });
$picker.instance.setData({ confirmBtn: '完成' });
await simulate.sleep();

const $confirm = $picker.querySelector('.t-picker__confirm');
expect($confirm).toBeDefined();
expect($confirm.dom.textContent.trim()).toBe('完成');
});

it(':change', async () => {
const comp = simulate.render(id);
comp.attach(document.createElement('parent-wrapper'));
Expand Down
2 changes: 0 additions & 2 deletions packages/components/picker/_example/area/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
visible="{{areaVisible}}"
value="{{areaValue}}"
title="选择地区"
cancelBtn="取消"
confirmBtn="确认"
usingCustomNavbar
bindchange="onPickerChange"
bindpick="onColumnChange"
Expand Down
4 changes: 0 additions & 4 deletions packages/components/picker/_example/base/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
value="{{cityValue}}"
data-key="city"
title="选择城市"
cancelBtn="取消"
confirmBtn="确认"
usingCustomNavbar
bindchange="onPickerChange"
bindpick="onColumnChange"
Expand All @@ -28,8 +26,6 @@
value="{{dateValue}}"
data-key="date"
title="选择时间"
cancelBtn="取消"
confirmBtn="确认"
usingCustomNavbar
bindchange="onPickerChange"
bindpick="onColumnChange"
Expand Down
4 changes: 0 additions & 4 deletions packages/components/picker/_example/with-title/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
value="{{cityValue}}"
data-key="city"
title="{{cityTitle}}"
cancelBtn="取消"
confirmBtn="确认"
usingCustomNavbar
bindchange="onPickerChange"
bindpick="onColumnChange"
Expand All @@ -22,8 +20,6 @@
value="{{city2Value}}"
data-key="city2"
title="{{city2Title}}"
cancelBtn="取消"
confirmBtn="确认"
usingCustomNavbar
bindchange="onPickerChange"
bindpick="onColumnChange"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
usePopup="{{false}}"
data-key="city"
title="{{cityTitle}}"
cancelBtn="取消"
confirmBtn="确认"
usingCustomNavbar
bindchange="onPickerChange"
bindpick="onColumnChange"
Expand Down
12 changes: 6 additions & 6 deletions packages/components/picker/template.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<view slot="content" style="{{_._style([style, customStyle])}}" class="{{classPrefix}} {{prefix}}-class">
<view class="{{classPrefix}}__toolbar" wx:if="{{header}}">
<view class="{{classPrefix}}__cancel {{prefix}}-class-cancel" wx:if="{{cancelBtn}}" bindtap="onCancel"
>{{globalConfig.cancel}}</view
>
<view class="{{classPrefix}}__cancel {{prefix}}-class-cancel" wx:if="{{cancelBtn}}" bindtap="onCancel">
{{cancelBtn === true ? globalConfig.cancel : cancelBtn}}
</view>
<view class="{{classPrefix}}__title {{prefix}}-class-title">{{title}}</view>
<view class="{{classPrefix}}__confirm {{prefix}}-class-confirm" wx:if="{{confirmBtn}}" bindtap="onConfirm"
>{{globalConfig.confirm}}</view
>
<view class="{{classPrefix}}__confirm {{prefix}}-class-confirm" wx:if="{{confirmBtn}}" bindtap="onConfirm">
{{confirmBtn === true ? globalConfig.confirm : confirmBtn}}
</view>
</view>
<slot name="header" />

Expand Down
6 changes: 6 additions & 0 deletions packages/tdesign-miniprogram/.changelog/pr-4480.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
pr_number: 4480
contributor: liweijie0812
---

- fix(Picker): 修复按钮自定义文案无效 @liweijie0812 ([#4480](https://github.com/Tencent/tdesign-miniprogram/pull/4480))
6 changes: 6 additions & 0 deletions packages/tdesign-uniapp/.changelog/pr-4480.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
pr_number: 4480
contributor: liweijie0812
---

- fix(Picker): 修复按钮自定义文案无效 @liweijie0812 ([#4480](https://github.com/Tencent/tdesign-miniprogram/pull/4480))
2 changes: 0 additions & 2 deletions packages/uniapp-components/picker/_example/area/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
:visible="areaVisible"
:value="areaValue"
title="选择地区"
cancel-btn="取消"
confirm-btn="确认"
:using-custom-navbar="!isMPAlipay"
@update:visible="(e) => areaVisible = e"
@change="onPickerChange"
Expand Down
2 changes: 0 additions & 2 deletions packages/uniapp-components/picker/_example/base/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
:value="cityValue"
data-key="city"
title="选择城市"
cancel-btn="取消"
confirm-btn="确认"
:using-custom-navbar="!isMPAlipay"
@update:visible="(e) => cityVisible = e"
@change="(e) => onPickerChange(e, { key: 'city' })"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
:value="cityValue"
data-key="city"
:title="cityTitle"
cancel-btn="取消"
confirm-btn="确认"
:using-custom-navbar="!isMPAlipay"
@update:visible="(e) => cityVisible = e"
@change="(e) => onPickerChange(e, { key: 'city' })"
Expand All @@ -38,8 +36,6 @@
:value="city2Value"
data-key="city2"
:title="city2Title"
cancel-btn="取消"
confirm-btn="确认"
:using-custom-navbar="!isMPAlipay"
@update:visible="(e) => city2Visible = e"
@change="(e) => onPickerChange(e, { key: 'city2' })"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
:use-popup="false"
data-key="city"
:title="cityTitle"
cancel-btn="取消"
confirm-btn="确认"
:using-custom-navbar="!isMPAlipay"
@update:visible="(e) => cityVisible = e"
@change="(e) => onPickerChange(e, { key: 'city' })"
Expand Down
8 changes: 4 additions & 4 deletions packages/uniapp-components/picker/picker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
:class="classPrefix + '__cancel ' + tClassCancel"
@click="onCancel"
>
{{ globalConfig.cancel }}
{{ cancelBtn === true ? globalConfig.cancel : cancelBtn }}
</view>
<view :class="classPrefix + '__title ' + tClassTitle">
{{ title }}
Expand All @@ -36,7 +36,7 @@
:class="classPrefix + '__confirm ' + tClassConfirm"
@click="onConfirm"
>
{{ globalConfig.confirm }}
{{ confirmBtn === true ? globalConfig.confirm : confirmBtn }}
</view>
</view>
<slot name="header" />
Expand Down Expand Up @@ -72,7 +72,7 @@
:class="classPrefix + '__cancel ' + tClassCancel"
@click="onCancel"
>
{{ globalConfig.cancel }}
{{ cancelBtn === true ? globalConfig.cancel : cancelBtn }}
</view>
<view :class="classPrefix + '__title ' + tClassTitle">
{{ title }}
Expand All @@ -82,7 +82,7 @@
:class="classPrefix + '__confirm ' + tClassConfirm"
@click="onConfirm"
>
{{ globalConfig.confirm }}
{{ confirmBtn === true ? globalConfig.confirm : confirmBtn }}
</view>
</view>
<slot name="header" />
Expand Down
Loading