-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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/Enhancement] Pass PanelHeader props to the onClick handler of action items #1181
Conversation
@@ -297,7 +297,7 @@ function PanelHeaderFactory(SaveExportDropdown, CloudStorageDropdown) { | |||
if (item.dropdownComponent) { | |||
showExportDropdown(item.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we ever have an action item that both shows a dropdown and does something on click? If not, then I can update this to return after this statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My 2 cents: either-or is a reasonable assumption, weird to do both.
Signed-off-by: Wesam Manassra <[email protected]>
06a5fb0
to
28dddbd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice short diff! The downside is you get a lot of comments...
@@ -297,7 +297,7 @@ function PanelHeaderFactory(SaveExportDropdown, CloudStorageDropdown) { | |||
if (item.dropdownComponent) { | |||
showExportDropdown(item.id); | |||
} | |||
item.onClick(); | |||
item.onClick && item.onClick(this.props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we actually need to pass all the props, or can we just pick the one(s) we need? I generally favor more careful approach (eventually with companion types).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do we do that? The action can choose to call any action bound prop, which would be hard to predict here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea for that you will need to add a getProp
property to the item and have the items decide which prop to pass to onClick
. performance wise, it's not going to matter. if just for the purpose of expose less props, maybe...but people would still need to know what are the props to choose from though, and they can just say give me all the props
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. With regards to getProp
, they still have to derive it from all props, which would be the same problem as passing this.props
to onClick
.
@@ -297,7 +297,7 @@ function PanelHeaderFactory(SaveExportDropdown, CloudStorageDropdown) { | |||
if (item.dropdownComponent) { | |||
showExportDropdown(item.id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My 2 cents: either-or is a reasonable assumption, weird to do both.
@@ -297,7 +297,7 @@ function PanelHeaderFactory(SaveExportDropdown, CloudStorageDropdown) { | |||
if (item.dropdownComponent) { | |||
showExportDropdown(item.id); | |||
} | |||
item.onClick(); | |||
item.onClick && item.onClick(this.props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe init onClick to noop and drop the if?
@@ -297,7 +297,7 @@ function PanelHeaderFactory(SaveExportDropdown, CloudStorageDropdown) { | |||
if (item.dropdownComponent) { | |||
showExportDropdown(item.id); | |||
} | |||
item.onClick(); | |||
item.onClick && item.onClick(this.props); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea for that you will need to add a getProp
property to the item and have the items decide which prop to pass to onClick
. performance wise, it's not going to matter. if just for the purpose of expose less props, maybe...but people would still need to know what are the props to choose from though, and they can just say give me all the props
Signed-off-by: Wesam Manassra <[email protected]>
PanelHeader
has a prop calledactionItems
which contains a list of actions, each with aid
,tooltip
,iconComponent
,dropDownComponent
and anonClick
handler:In order for the
onClick
handler to be able to dispatch actions, it needs access to thePanelHeader
's prop, which this PR adds.