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

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

Conversation

kuri-sun
Copy link
Member

@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.

Copy link

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

Copy link

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

Copy link

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.

@@ -127,7 +127,7 @@ export function useDropdown(props: UseDropdownProps) {
const {onKeyDown, onPress, onPressStart, ...otherMenuTriggerProps} = menuTriggerProps;

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

Choose a reason for hiding this comment

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

Copy link
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
Member 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(

).
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
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
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
3 participants