Skip to content

Commit

Permalink
fix(QDate): only refocus blurTarget if focus is already in component #…
Browse files Browse the repository at this point in the history
…14841, #14878 (#14868)

fix(QDate): only refocus blurTarget if focus is already in component #14841
  • Loading branch information
pdanpdan committed Nov 14, 2022
1 parent 631e883 commit 1b7b63b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions ui/dev/src/pages/form/date-part1-basic.vue
Expand Up @@ -333,6 +333,24 @@
</template>
</q-input>
</div>

<div class="text-h6">
Input that keeps focus: {{ input }}
</div>
<div class="q-gutter-md">
<q-input :dark="dark" filled v-model="inputFull" label="Keep focus here" @focus="e => $refs.menuRef.show(e)" @blur="e => $refs.menuRef.hide(e)">
<q-menu ref="menuRef" anchor="bottom left" self="top left" no-focus no-refocus no-parent-event>
<q-date
v-model="inputFull"
v-bind="props"
mask="YYYY-MM-DD HH:mm"
today-btn
:style="style"
@pointerdown.capture.prevent
/>
</q-menu>
</q-input>
</div>
</div>
</div>
</template>
Expand Down
4 changes: 3 additions & 1 deletion ui/src/components/date/QDate.js
Expand Up @@ -708,7 +708,9 @@ export default createComponent({
})

watch(view, () => {
blurTargetRef.value !== null && blurTargetRef.value.focus()
if (blurTargetRef.value !== null && proxy.$el.contains(document.activeElement) === true) {
blurTargetRef.value.focus()
}
})

watch(() => viewModel.value.year, year => {
Expand Down

0 comments on commit 1b7b63b

Please sign in to comment.