Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcff890d

Browse files
committed
fix(activator):fix#53
1 parent700a577 commitcff890d

File tree

3 files changed

+33
-2
lines changed

3 files changed

+33
-2
lines changed

‎src/components/Picker.vue‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<divclass="md-date-range-picker"v-clickoutside="clickOutside">
33
<divclass="md-date-range-picker__activator"@click="togglePicker">
44
<slotname="input">
5-
<default-activator:value="`${startText} - ${endText}`"readonly />
5+
<default-activatorref="defaultActivator":value="`${startText} - ${endText}`"readonly />
66
</slot>
77
</div>
88
<transitionname="slide-fade"mode="out-in">
@@ -236,7 +236,34 @@ export default {
236236
}
237237
},
238238
togglePicker () {
239-
this.pickerVisible=!this.pickerVisible;
239+
// ---- fix #53 start ----
240+
let elm=this.$refs.defaultActivator&&this.$refs.defaultActivator.$el;
241+
constslotActivator=this.$slots.input&&this.$slots.input.length&&this.$slots.input[0];
242+
if (!elm&& (slotActivator.querySelector('input')||slotActivator.querySelector('button'))) {
243+
elm= slotActivator;
244+
}
245+
246+
if (elm) {
247+
// 1. dont return or do nothing here,
248+
// because you need to show the picker panel if the picker panel is hidden(example: user click the activator first time)
249+
// but `this.pickerVisible = !this.pickerVisible;` do the samething in this case.
250+
// So why set pickerVisible always `true` if elm exist?
251+
// 2. [interact]: because if the type of activator is input or button and the picker panel is already visible (pickerVisible === true),
252+
// when the user click the activator, the picker panel should keep visible(can not fold the picker panel)
253+
254+
// Chinese:
255+
// 1. 不能在这里 return 或 啥都不做
256+
// 因为如果日期选择器是隐藏的,点击了 input 需要显示日期选择器。比如用户第一次点击日期选择器的时候
257+
// 但是在这种情况下做,下面的 `this.pickerVisible = !this.pickerVisible;` 做了一样的事
258+
// 那么为何需要在 elm 为 true 的时候,总是设置 pickerVisible 为 true 呢?
259+
// 2. [交互] 我们约定,当 activator 的类型是 input 或 button,以及 选择器面板已经 打开的情况下,
260+
// 当用户点击了 activator 的时候,不收起日期选择器面板
261+
262+
this.pickerVisible=true;
263+
}else {
264+
this.pickerVisible=!this.pickerVisible;
265+
}
266+
// ---- fix #53 start ----
240267
},
241268
pickerStyles () {
242269
return {

‎src/styles/components/activator.scss‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
.md-date-range-picker__activator {
2+
display:inline-block;
3+
}
14
.md-date-range-picker__activator.activator-wrapper {
25
position:relative;
36

‎src/styles/components/picker.scss‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
/* gs-date-range-picker-container*/
9494
.md-date-range-picker {
9595
position:relative;
96+
display:inline-block;
9697
}
9798

9899
$prefix-class: daterangepicker;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp