FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(Dropdown split button): Add 3rd state to split button by karelhala · Pull Request #2842 · patternfly/patternfly-react · GitHub

fix(Dropdown split button): Add 3rd state to split button - #2842

Merged
tlabaj merged 2 commits into
patternfly:masterfrom
karelhala:3rd-state-split
Sep 23, 2019
Merged

fix(Dropdown split button): Add 3rd state to split button#2842
tlabaj merged 2 commits into
patternfly:masterfrom
karelhala:3rd-state-split

Conversation

Copy link
Copy Markdown
Contributor

Fixes: #2841

What:
In order to allow 3rd state in checkbox of split button we have to use Checkbox component.

Additional issues:

type="checkbox"
onChange={this.handleChange}
{...(this.calculateChecked() !== undefined) && { onChange: this.handleChange }}
ref={ref as any}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Anybody knows something better to use here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why do you have to pass the ref here? It will be passed automatically with {...props} with the correct type.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It's because TS does not recognized the ref correctly in here. I tried casting it to expected and it failed. This was the only solution that didn't thre any error.

Copy link
Copy Markdown
Collaborator

PatternFly-React preview: https://patternfly-react-pr-2842.surge.sh

karelhala force-pushed the 3rd-state-split branch 3 times, most recently from ae9c588 to a6e29b8 Compare September 5, 2019 13:12
expect(view).toMatchSnapshot();
});

test('checkbox passes value and event to onChange handler', () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I had to remove this test because jest is not playing nicely with mount and currentTarget enzymejs/enzyme#218.

I had to use mount because checkbox is now in Checkbox component.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I've run into this same issue (I think also with Checkbox). My solution was to change handleChange in Checkbox.tsx from:

private handleChange = (event: React.FormEvent<HTMLInputElement>): void => {
  this.props.onChange(event.currentTarget.checked, event);
}

to:

private handleChange = (event: React.FormEvent<HTMLInputElement>): void => {
  this.props.onChange(event.target.checked, event);
}

If Checkbox doesn't break, feel free to try that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think we should open a high-priority issue to add this test back if we aren't willing to address it in the scope of this PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Yeah, that came up in head as well, I didn't wanted to change the original Checkbox though because it's not part of this PR. But I'll probably change it to use target instead of currentTarget.

I could also change handleChange of this component to use target instead of currentTarget which is probably a bit safer.

mcarrano previously approved these changes Sep 17, 2019

mcarrano left a comment

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks good @karelhala

mcoker previously approved these changes Sep 17, 2019

mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm! 🏆

kmcfaul previously approved these changes Sep 18, 2019
tlabaj previously approved these changes Sep 19, 2019

tlabaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you please resolve merge conflicts so we can get his one in. Thanks!

karelhala dismissed stale reviews from tlabaj, kmcfaul, mcoker, and mcarrano via 14111cc September 23, 2019 12:24

tlabaj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

tlabaj merged commit 6cb6424 into patternfly:master Sep 23, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Dropdown Split button 3rd state input

7 participants


Back | FazBrowse Home | New Git URL