Skip to content

fix(components): getMenuTriggerProps in use-dropdown.ts returns origi…#2451

Closed
kuri-sun wants to merge 1 commit into
heroui-inc:mainfrom
kuri-sun:getMenuTriggerProps-in-use-dropdown.ts-returns-origina
Closed

fix(components): getMenuTriggerProps in use-dropdown.ts returns origi…#2451
kuri-sun wants to merge 1 commit into
heroui-inc:mainfrom
kuri-sun:getMenuTriggerProps-in-use-dropdown.ts-returns-origina

Conversation

@kuri-sun
Copy link
Copy Markdown

@kuri-sun kuri-sun commented Mar 5, 2024

…nalProps as Object

Closes #2448

📝 Description

As per request from @wingkwong for the review of this PR, since my last change was affecting this matter.

⛳️ Current behavior (updates)

isDisabled does not disable dropdown.

🚀 New behavior

  • To fix this, we intentionally use props.isDisabled to take the isDisabled prop from the Dropdown component in effect as well.
  • No more appear in HTML as originalProps=[Object Object].
dropdonw.mov

💣 Is this a breaking change (Yes/No):

No.

📝 Additional Information

No.

@kuri-sun kuri-sun requested a review from jrgarciadev as a code owner March 5, 2024 12:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 5, 2024

🦋 Changeset detected

Latest commit: 18de527

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@nextui-org/dropdown Major
@nextui-org/react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextui-storybook-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 5, 2024 0:29am

@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 5, 2024

@kuri-sun is attempting to deploy a commit to the NextUI Inc Team on Vercel.

A member of the Team first needs to authorize it.


return {
...mergeProps(otherMenuTriggerProps, {isDisabled}, originalProps),
...mergeProps(otherMenuTriggerProps, {isDisabled: props.isDisabled}, originalProps),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kuri-sun Ya I changed to {isDisabled} because I've noticed that it's from props so I refactored a bit. I was wondering the difference as well. Moreover, if I don't set isDisabled, then {isDisabled: props.isDisabled} would become isDisabled: undefined after merged. Taking {isDisabled} doesn't have such problem since by default we set it as false.

Copy link
Copy Markdown
Author

@kuri-sun kuri-sun Mar 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrgarciadev and @wingkwong
When the isDisabled does not get passed to the Dropdown component, it always becomes isDisabled=false(https://github.com/nextui-org/nextui/blob/9b27da544e950cdb2bccd2d1a57ead772fd10dc1/packages/components/dropdown/src/use-dropdown.ts#L53).
So I was worrying about this situation: the trigger Button component was disabled however the still is enabled.

  1. isDisabled (Current)
children.mov
  1. props.isDisabled (This one)
this-change.mov

By setting {isDisabled: props.isDisabled}, it becomes isDisabled: undefined, so that coming the Button's isDisabled can override that, if there is any isDisabled on the Button component.

However, if we can ignore the trigger Button component's isDisabled in this case, I would agree with going with it as it is! 😄

Sorry for the long explanation... I hope this makes sense! Thank you! ❤️

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I finally got what you mean. I can see why we need undefined here now. It wasn't that obvious though. @jrgarciadev Should we cover this case as well?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrgarciadev jrgarciadev closed this Mar 5, 2024
@kuri-sun kuri-sun deleted the getMenuTriggerProps-in-use-dropdown.ts-returns-origina branch March 14, 2024 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] - getMenuTriggerProps in use-dropdown.ts returns originalProps as Object

4 participants