fix(index): 修复选预设时长时页面向上跳动
input 聚焦键盘弹起时点预设,onSelectPreset 清空 customInput 触发 adjust-position 重算导致页面上跳。点预设时先失焦 input 收键盘。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,7 @@ Page({
|
|||||||
planTotal: 7,
|
planTotal: 7,
|
||||||
planProgress: 0,
|
planProgress: 0,
|
||||||
showPicker: false,
|
showPicker: false,
|
||||||
|
pickerInputFocus: false,
|
||||||
presets: [30, 60, 90, 120, 180, 300],
|
presets: [30, 60, 90, 120, 180, 300],
|
||||||
customDuration: 60,
|
customDuration: 60,
|
||||||
customInput: '',
|
customInput: '',
|
||||||
@@ -170,7 +171,12 @@ Page({
|
|||||||
|
|
||||||
onSelectPreset(e) {
|
onSelectPreset(e) {
|
||||||
const val = e.currentTarget.dataset.value
|
const val = e.currentTarget.dataset.value
|
||||||
this.setData({ customDuration: val, customInput: '' })
|
// 收起键盘(失焦 input),避免清空 customInput 时触发 adjust-position 让页面向上跳
|
||||||
|
this.setData({ pickerInputFocus: false, customDuration: val, customInput: '' })
|
||||||
|
},
|
||||||
|
|
||||||
|
onPickerInputFocus() {
|
||||||
|
this.setData({ pickerInputFocus: true })
|
||||||
},
|
},
|
||||||
|
|
||||||
onCustomInput(e) {
|
onCustomInput(e) {
|
||||||
|
|||||||
@@ -118,7 +118,9 @@
|
|||||||
type="number"
|
type="number"
|
||||||
placeholder="输入秒数"
|
placeholder="输入秒数"
|
||||||
value="{{customInput}}"
|
value="{{customInput}}"
|
||||||
|
focus="{{pickerInputFocus}}"
|
||||||
bindinput="onCustomInput"
|
bindinput="onCustomInput"
|
||||||
|
bindfocus="onPickerInputFocus"
|
||||||
/>
|
/>
|
||||||
<text class="custom-label">秒</text>
|
<text class="custom-label">秒</text>
|
||||||
</view>
|
</view>
|
||||||
|
|||||||
Reference in New Issue
Block a user