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 prop isShared #3640

Merged
merged 1 commit into from
Dec 14, 2023
Merged

Conversation

josemigallas
Copy link
Contributor

@josemigallas josemigallas commented Nov 28, 2023

@josemigallas josemigallas requested a review from lvillen November 28, 2023 10:53
@josemigallas josemigallas self-assigned this Nov 28, 2023
lvillen
lvillen previously approved these changes Nov 30, 2023
<OverflowMenuItem key={label}>
<Button component="a" {...btnProps}>{label}</Button>
</OverflowMenuItem>
))}
</OverflowMenuGroup>
</OverflowMenuContent>
<OverflowMenuControl hasAdditionalOptions={overflow.some(i => !i.isShared)}>
<OverflowMenuControl hasAdditionalOptions={overflow.some(i => !i.shared)}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm, it's a bit weird to negate a string 🤔

'cause !'false' == false, which might be confusing.

Why is this change done in the first place?...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, it's a bit weird to negate a string 🤔
'cause !'false' == false, which might be confusing.

It's supposed to be a boolean though.

On the other hand, HTML boolean attributes only care about its presence, not the actual value. That means these are the same:

<input disabled="false" />
<input disabled="true" />

Why is this change done in the first place?...
It's explained in the JIRA. isShared looks like a React props but it's passed to the HTML elements directly, so it should be named isshared.

This attribute does nothing to the element really, we could remove it instead of passing it down. But IMHO it's more trouble than it's worth.

Copy link
Contributor

Choose a reason for hiding this comment

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

I've been looking into this, and I have a question:

isShared looks like a React props but it's passed to the HTML elements directly, so it should be named isshared.

But why do we need to pass it to HTML? 🤔

It looks like it's actually indeed a React (specifically Patternfly4 React) thing?...

https://v4-archive.patternfly.org/v4/components/overflow-menu#overflowmenudropdownitem

The naming is extremely confusing, by the way, "isShared" by whom?... So, if PF React really needs this, we probably shouldn't rename and should just avoid propagating this to HTML? 🤔

If in our implementation we don't need this React thing, we could also rename it to something more meaningful, like "alwaysHidden" defaulting to false (boolean)

Copy link
Contributor

Choose a reason for hiding this comment

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

And by the way, I don't see the need to place the two buttons on the toolbar to the overflow menu... I would just keep them in actions. But well, that's fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oof, OK you're right, I completely lost sight of the real issue. isShared is passed both to Button and OverflowMenuDropdownItem but it's a prop of the latter and therefore an error is thrown for Button.

But the name can't change so I'm going to "remove" the attribute from btnProps so that it's not passed down to Button so that no error is thrown.

Such a good review @mayorova, thanks!

@josemigallas josemigallas merged commit ec82abc into master Dec 14, 2023
3 of 5 checks passed
@josemigallas josemigallas deleted the THREESCALE-10506_toolbar_shared branch December 14, 2023 14:15
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.

3 participants