mirror of
https://github.com/primefaces/primevue.git
synced 2025-05-09 00:42:36 +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');
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
:data-p-focused="isItemFocused()"
|
||||
:data-p-disabled="disabled() || false"
|
||||
>
|
||||
<div :class="cx('content')" @click="onItemClick($event)" v-bind="getPTOptions('content')">
|
||||
<div :class="cx('content')" @click="onItemClick($event)" @mousemove="onItemMouseMove($event)" v-bind="getPTOptions('content')">
|
||||
<template v-if="!templates.item">
|
||||
<a v-ripple :href="item.url" :class="cx('action')" :target="item.target" tabindex="-1" aria-hidden="true" v-bind="getPTOptions('action')">
|
||||
<component v-if="templates.itemicon" :is="templates.itemicon" :item="item" :class="cx('icon')" />
|
||||
|
@ -35,7 +35,7 @@ export default {
|
|||
hostName: 'Menu',
|
||||
extends: BaseComponent,
|
||||
inheritAttrs: false,
|
||||
emits: ['item-click'],
|
||||
emits: ['item-click', 'item-mousemove'],
|
||||
props: {
|
||||
item: null,
|
||||
templates: null,
|
||||
|
@ -66,6 +66,9 @@ export default {
|
|||
command && command({ originalEvent: event, item: this.item.item });
|
||||
this.$emit('item-click', { originalEvent: event, item: this.item, id: this.id });
|
||||
},
|
||||
onItemMouseMove(event) {
|
||||
this.$emit('item-mousemove', { originalEvent: event, item: this.item, id: this.id });
|
||||
},
|
||||
visible() {
|
||||
return typeof this.item.visible === 'function' ? this.item.visible() : this.item.visible !== false;
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue