mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-11 09:52:35 +00:00
Fixed #5288 - Menu components: track focus with also mousemove
This commit is contained in:
parent
266d5019af
commit
e67efa2d8c
10 changed files with 91 additions and 29 deletions
|
@ -25,12 +25,21 @@
|
|||
<slot name="submenuheader" :item="item">{{ label(item) }}</slot>
|
||||
</li>
|
||||
<template v-for="(child, j) of item.items" :key="child.label + i + '_' + j">
|
||||
<PVMenuitem v-if="visible(child) && !child.separator" :id="id + '_' + i + '_' + j" :item="child" :templates="$slots" :focusedOptionId="focusedOptionId" @item-click="itemClick" :pt="pt" />
|
||||
<PVMenuitem
|
||||
v-if="visible(child) && !child.separator"
|
||||
:id="id + '_' + i + '_' + j"
|
||||
:item="child"
|
||||
:templates="$slots"
|
||||
:focusedOptionId="focusedOptionId"
|
||||
@item-click="itemClick"
|
||||
@item-mousemove="itemMouseMove"
|
||||
:pt="pt"
|
||||
/>
|
||||
<li v-else-if="visible(child) && child.separator" :key="'separator' + i + j" :class="[cx('separator'), item.class]" :style="child.style" role="separator" v-bind="ptm('separator')"></li>
|
||||
</template>
|
||||
</template>
|
||||
<li v-else-if="visible(item) && item.separator" :key="'separator' + i.toString()" :class="[cx('separator'), item.class]" :style="item.style" role="separator" v-bind="ptm('separator')"></li>
|
||||
<PVMenuitem v-else :key="label(item) + i.toString()" :id="id + '_' + i" :item="item" :index="i" :templates="$slots" :focusedOptionId="focusedOptionId" @item-click="itemClick" :pt="pt" />
|
||||
<PVMenuitem v-else :key="label(item) + i.toString()" :id="id + '_' + i" :item="item" :index="i" :templates="$slots" :focusedOptionId="focusedOptionId" @item-click="itemClick" @item-mousemove="itemMouseMove" :pt="pt" />
|
||||
</template>
|
||||
</ul>
|
||||
<div v-if="$slots.end" :class="cx('end')" v-bind="ptm('end')">
|
||||
|
@ -116,15 +125,14 @@ export default {
|
|||
this.focusedOptionIndex = event.id;
|
||||
}
|
||||
},
|
||||
itemMouseMove(event) {
|
||||
if (this.focused) {
|
||||
this.focusedOptionIndex = event.id;
|
||||
}
|
||||
},
|
||||
onListFocus(event) {
|
||||
this.focused = true;
|
||||
|
||||
if (!this.popup) {
|
||||
if (this.selectedOptionIndex !== -1) {
|
||||
this.changeFocusedOptionIndex(this.selectedOptionIndex);
|
||||
this.selectedOptionIndex = -1;
|
||||
} else this.changeFocusedOptionIndex(0);
|
||||
}
|
||||
!this.popup && this.changeFocusedOptionIndex(0);
|
||||
|
||||
this.$emit('focus', event);
|
||||
},
|
||||
|
@ -255,7 +263,6 @@ export default {
|
|||
|
||||
if (this.popup) {
|
||||
DomHandler.focus(this.list);
|
||||
this.changeFocusedOptionIndex(0);
|
||||
}
|
||||
|
||||
this.$emit('show');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue