Skip to content

Commit

Permalink
Fixed #13934
Browse files Browse the repository at this point in the history
  • Loading branch information
cetincakiroglu committed Dec 28, 2023
1 parent 6036d1f commit ad15d71
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/app/components/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ad15d71

Please sign in to comment.