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

[Bug]: Dynamic menu items lose reference to currentItem in list. #35706

Open
1 task done
Kye-NG opened this issue Aug 15, 2024 · 5 comments
Open
1 task done

[Bug]: Dynamic menu items lose reference to currentItem in list. #35706

Kye-NG opened this issue Aug 15, 2024 · 5 comments
Assignees
Labels
Bug Something isn't working Community Reported issues reported by community members High This issue blocks a user from building or impacts a lot of users Menu Button Widget Issues related to Menu Button widget Needs Triaging Needs attention from maintainers to triage Production Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets

Comments

@Kye-NG
Copy link

Kye-NG commented Aug 15, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Description

Dynamic menu buttons lose reference to currentItem inside of the onClick event when the widget is inside of a list.

Using currentItem.value within the onclick event of a dynamic menu item works as is, but when the menu is inside of a list currentItem.value is undefined.

Steps To Reproduce

  1. Create a Menu Button widget.
    image

  2. Set the menu items source to "Dynamic".

  3. Set the "Source data" to the following or something similar {{[{ label: 'test1', value: 'banana'}, { label: 'test2', value: 'orange'}] }}.

  4. Configure the menu items as follows, and as seen on the example page.

  5. Label: {{ currentItem.label}};

  6. Onclick: {{showAlert(currentItem.value, 'success')}};
    image

  7. Click on one of the options and the showAlert will pop up with the value.
    image

  8. Drag and drop or copy the menu button widget into a list item, and it will return showAlert expected STRING for 'message' argument but received UNDEFINED.
    image

Public Sample App

No response

Environment

Production

Severity

High (Blocker to building or releasing)

Issue video log

No response

Version

Self hosted: v1.14 and also v1.23

@Kye-NG Kye-NG added Bug Something isn't working Needs Triaging Needs attention from maintainers to triage labels Aug 15, 2024
@Nikhil-Nandagopal Nikhil-Nandagopal added Community Reported issues reported by community members Critical This issue needs immediate attention. Drop everything else High This issue blocks a user from building or impacts a lot of users Production labels Aug 15, 2024
@Nikhil-Nandagopal
Copy link
Contributor

@Kye-NG in this case you should use the List1.selectedItem or List1.triggeredItem

@Nikhil-Nandagopal Nikhil-Nandagopal removed Critical This issue needs immediate attention. Drop everything else High This issue blocks a user from building or impacts a lot of users labels Aug 15, 2024
@Kye-NG
Copy link
Author

Kye-NG commented Aug 15, 2024

That gives me the metadata of the list item itself, i want to access the data of the dynamic menu button that i clicked on.

both List1.selectedItem and List1.triggeredItem contain
image

But i'm expecting { label: 'test1', value: 'banana'} which is the clicked button's data.

@Nikhil-Nandagopal
Copy link
Contributor

@Kye-NG use the selectedItemView then

@Kye-NG
Copy link
Author

Kye-NG commented Aug 16, 2024

@Nikhil-Nandagopal that also doesn't contain the data of the button i clicked... to reiterate, i don't want the metadata of the list item, i want the metadata of the button that i clicked on.

Have you tried the reproducible steps? It's quite easy to understand that when the button is outside of the list, the onclick event can access the buttons values when clicked using currentItem, but if it's put inside of a list it no longer has those values attached to currentItem.

Since it's a dynamic menu (which will be based off of the data from the list), currently without having access to currentItem values for the button, I won't be able to know which button is being clicked.

@Nikhil-Nandagopal
Copy link
Contributor

@Kye-NG ok I now see the problem. This is specifically for dynamic menus inside a list when you need to know which menu item inside the menu button inside the list is clicked

@Nikhil-Nandagopal Nikhil-Nandagopal added High This issue blocks a user from building or impacts a lot of users Menu Button Widget Issues related to Menu Button widget labels Aug 16, 2024
@github-actions github-actions bot added Widgets Product This label groups issues related to widgets Widgets & Accelerators Pod Issues related to widgets & Accelerators labels Aug 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Community Reported issues reported by community members High This issue blocks a user from building or impacts a lot of users Menu Button Widget Issues related to Menu Button widget Needs Triaging Needs attention from maintainers to triage Production Widgets & Accelerators Pod Issues related to widgets & Accelerators Widgets Product This label groups issues related to widgets
Projects
None yet
Development

No branches or pull requests

6 participants