Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TabMenu:(activeItemChange) runs twice #16346

Open
MarcoPasta opened this issue Sep 4, 2024 · 3 comments
Open

TabMenu:(activeItemChange) runs twice #16346

MarcoPasta opened this issue Sep 4, 2024 · 3 comments
Labels
Resolution: Help Wanted Issue or pull request requires extra help and feedback
Milestone

Comments

@MarcoPasta
Copy link

Describe the bug

When using the TabMenu component and working with (activeItemChange) i ecnounter the problem that the method i pass is run at least twice. This causes the problem to handle conditional user navigation.

example: A user is currently on page 'profile' and has unsaved data here. When the user clicks on dashboard on the TabMenu, a popup comes up asking if he wants to leave, unsaved data will be deleted. In the background, a copy of the current activeItem profile is made (prevItem) and the new item (dashboard) will be written inside the current active Item. When the user hits 'cancel', he will stay in his component and the active item will be changed back to prevItem.

Unfortunately, due to the method running twice, the previous item will always overwritten, resulting in it always being the new item:

image

Environment

Angular 17 used in Intellij Ultimate 2024.1.4

Reproducer

No response

Angular version

17.3.8

PrimeNG version

17.13.0

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

v20.12.2

Browser(s)

128.0.6613.114

Steps to reproduce the behavior

  1. insert tabmenu component
  2. create menu items array & active item
  3. insert a few logs an create onChange method
  4. set things in to place
  5. watch the console

Expected behavior

The method should run once so when i save the current activeItem on change, it won't be overwritten when the methods runs a second time

Bildschirmfoto 2024-09-04 um 18 16 06

@MarcoPasta MarcoPasta added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 4, 2024
@OleksiiPrykhodko
Copy link

I found the same problem in the version 18.0.0-beta.2 .

@mertsincan mertsincan added Resolution: Help Wanted Issue or pull request requires extra help and feedback and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 4, 2024
@mertsincan mertsincan added this to the Future milestone Dec 4, 2024
Copy link

github-actions bot commented Dec 4, 2024

Due to PrimeNG team's busy roadmap, this issue is available for anyone to work on. Make sure to reference this issue in your pull request. ✨ Thank you for your contribution! ✨

@Jimmy-sheep
Copy link

Jimmy-sheep commented Dec 9, 2024

Normally it output twice time, the first time output the original selected MenuItem, and second time output the newly selected MenuItem. But if the two times you select the same option, it will only output the original selected MenuItem.

P.S. Tested by <p-tabmenu>, not sure will happen on <p-tabView> or not

@github-project-automation github-project-automation bot moved this to Review in PrimeNG Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Help Wanted Issue or pull request requires extra help and feedback
Projects
Status: Review
Development

No branches or pull requests

4 participants