| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| type="checkbox" | ||
| onChange={this.handleChange} | ||
| {...(this.calculateChecked() !== undefined) && { onChange: this.handleChange }} | ||
| ref={ref as any} |
There was a problem hiding this comment.
Anybody knows something better to use here?
Sorry, something went wrong.
There was a problem hiding this comment.
Why do you have to pass the ref here? It will be passed automatically with {...props} with the correct type.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
|
PatternFly-React preview: https://patternfly-react-pr-2842.surge.sh |
Sorry, something went wrong.
| expect(view).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| test('checkbox passes value and event to onChange handler', () => { |
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
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.
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good @karelhala
Sorry, something went wrong.
There was a problem hiding this comment.
lgtm! 🏆
Sorry, something went wrong.
There was a problem hiding this comment.
Can you please resolve merge conflicts so we can get his one in. Thanks!
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Fixes: #2841
What:
In order to allow 3rd state in checkbox of split button we have to use Checkbox component.
Additional issues: