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

feat(ClipboardCopy): added event to onChange prop #8747

Conversation

wise-king-sullyman
Copy link
Contributor

What: Closes #8698

Additional issues:

@@ -119,7 +119,7 @@ export class ClipboardCopy extends React.Component<ClipboardCopyProps, Clipboard
// eslint-disable-next-line @typescript-eslint/no-unused-vars
componentDidUpdate = (prevProps: ClipboardCopyProps, prevState: ClipboardCopyState) => {
if (prevProps.children !== this.props.children) {
this.updateText(this.props.children as string | number);
this.setState({ text: this.props.children as string | number });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed this to just set the state (rather than call updateText) as there is no event to pass to updateText and the onChange.

I think this should be fine, since the only way this conditional is met is that the change in value is coming via children passed to the component, in which case consumers should already be aware that the value is being changed, so the onChange coming from ClipboardCopy shouldn't be necessary.

If I'm thinking about that incorrectly though please let me know!

@patternfly-build
Copy link
Contributor

patternfly-build commented Feb 27, 2023

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

This looks good. The only thing that it looks like is that whenever TextInput has its update to its onChange callback, updateText may need to be updated again to switch the params, as will ClipboardCopyExpanded. Would be found by whomever works on that issue, but we could open the issue now to mention it.

@wise-king-sullyman
Copy link
Contributor Author

Ah good callout on ClipboardCopyExpanded, that should be within the scope of this PR IMO. TextInput already has a checkbox under the epic so I don't think a new issue is needed for that now?

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

TextInput already has a checkbox under the epic so I don't think a new issue is needed for that now?

Yeah it isn't necessary to do right now, especially since you added in the ClipboardCopyExpanded here

@nicolethoen nicolethoen merged commit ed13078 into patternfly:v5 Mar 1, 2023
@wise-king-sullyman wise-king-sullyman deleted the clipboard-copy-onchange-add-event branch March 1, 2023 18:41
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.

ClipboardCopy: add event param to onChange callback. It should be first parameter.
5 participants