From ad15d71f813d6e459e399c77c2ee34369f0974a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87etin?= <69278826+cetincakiroglu@users.noreply.github.com> Date: Thu, 28 Dec 2023 17:00:50 +0300 Subject: [PATCH] Fixed #13934 --- src/app/components/menu/menu.ts | 35 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/app/components/menu/menu.ts b/src/app/components/menu/menu.ts index 354e2b97f78..9f9ba355230 100755 --- a/src/app/components/menu/menu.ts +++ b/src/app/components/menu/menu.ts @@ -530,24 +530,28 @@ export class Menu implements OnDestroy { } onListFocus(event: Event) { - this.focused = true; - if (!this.popup) { - if (this.selectedOptionIndex() !== -1) { - this.changeFocusedOptionIndex(this.selectedOptionIndex()); - this.selectedOptionIndex.set(-1); - } else { - this.changeFocusedOptionIndex(0); + if (!this.focused) { + this.focused = true; + if (!this.popup) { + if (this.selectedOptionIndex() !== -1) { + this.changeFocusedOptionIndex(this.selectedOptionIndex()); + this.selectedOptionIndex.set(-1); + } else { + this.changeFocusedOptionIndex(0); + } } + this.onFocus.emit(event); } - this.onFocus.emit(event); } onListBlur(event: FocusEvent | MouseEvent) { - this.focused = false; - this.changeFocusedOptionIndex(-1); - this.selectedOptionIndex.set(-1); - this.focusedOptionIndex.set(-1); - this.onBlur.emit(event); + if (this.focused) { + this.focused = false; + this.changeFocusedOptionIndex(-1); + this.selectedOptionIndex.set(-1); + this.focusedOptionIndex.set(-1); + this.onBlur.emit(event); + } } onListKeyDown(event) { @@ -659,6 +663,11 @@ export class Menu implements OnDestroy { itemClick(event: any, id: string) { const { originalEvent, item } = event; + if (!this.focused) { + this.focused = true; + this.onFocus.emit(); + } + if (item.disabled) { originalEvent.preventDefault(); return;