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

Menu | disabled property as a function is not working with command prop #2365

Closed
marlonrichert opened this issue Mar 29, 2022 · 3 comments
Closed
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@marlonrichert
Copy link

Bug report

CodeSandbox Case

https://codesandbox.io/s/falling-cdn-8rlxcu?file=/src/MenuDemo.vue

Current behavior

In the menu model, if an object's disabled property is set to a function, then the corresponding Menu item's command no longer fires when clicked.

Expected behavior

According to the menu model documentation, disabled is allowed to be a boolean or a function returning a boolean.

Minimal reproduction of the problem with instructions

In the sandbox above, note that clicking Update does nothing, even though it has a valid command.

What is the motivation / use case for changing the behavior?

The implementation should match the documentation.

Environment

  • Vue 3.1.5
  • PrimeVue 3.12.2
  • All browsers
@tugcekucukoglu
Copy link
Member

This is expected behavior. Anchor link is disabled so click event do nothing.

@marlonrichert
Copy link
Author

marlonrichert commented Mar 29, 2022

@tugcekucukoglu

This is expected behavior.

It’s not expected behavior according to your documentation:

Name Type
disabled boolean/function

Anchor link is disabled so click event do nothing.

That’s not at all an accurate description of the bug’s cause. The real problem lies on this line:

if (item.disabled) {

It does not check if disabled is a function. According to your own documentation, disabled is allowed to be a function, just like visible. It should be checked in the same way that you check visible:

return (typeof item.visible === 'function' ? item.visible() : item.visible !== false);

@AndreasNasman
Copy link

@tugcekucukoglu The disable property is not working per the documentation.

In the example, @marlonrichert has set the disable property to a function returning false,

disabled: () => false,

meaning the Menu component should be enabled. In the current implementation, it's disabled, however. See Marlon's answer where it occurs in the source code.

Either the documentation should be fixed, or better, the code be fixed to handle the function case

@tugcekucukoglu tugcekucukoglu added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Apr 11, 2022
@tugcekucukoglu tugcekucukoglu changed the title Menu malfunctions when menu model property disabled is a function Menu | disabled property as a function is not working with command prop Apr 11, 2022
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Apr 11, 2022
@tugcekucukoglu tugcekucukoglu added this to the 3.12.5 milestone Apr 11, 2022
@tugcekucukoglu tugcekucukoglu self-assigned this Apr 11, 2022
tugcekucukoglu added a commit that referenced this issue Apr 11, 2022
Fixed #2365 - Menu | disabled property as a function is not working w…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants