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

RadioGroupProps.onChange is not a React.ChangeEventHandler<HTMLInputElement> #9574

Closed
whtsky opened this issue Mar 8, 2018 · 7 comments
Closed

Comments

@whtsky
Copy link
Contributor

whtsky commented Mar 8, 2018

Version

undefined

Environment

TypeScript

Reproduction link

https://codesandbox.io/s/jpw403mn3

Steps to reproduce

run, click a radio

What is expected?

show has cancelable

What is actually happening?

show no cancelable


React.ChangeEventHandler should receive a SyntheticEvent( https://github.com/DefinitelyTyped/DefinitelyTyped/blob/db8be7aec245c2158be0bc2c9a8a8c3f8cdfcd96/types/react/index.d.ts#L494, https://reactjs.org/docs/events.html ) , which must have cancelable, bubbles, etc. but the param passed by rc-checkbox is not a SyntheticEvent, see https://github.com/react-component/checkbox/blob/master/src/Checkbox.jsx#L66

@yesmeck
Copy link
Member

yesmeck commented Mar 8, 2018

e.nativeEvent

@yesmeck yesmeck closed this as completed Mar 8, 2018
@whtsky
Copy link
Contributor Author

whtsky commented Mar 8, 2018

I'm totally aware that we can use e.nativeEvent, but the type is wrong

@yesmeck
Copy link
Member

yesmeck commented Mar 8, 2018

Hmm, what scenario do you want to check cancelable? If you want to prevent the change event, you just do not update the state value.

@whtsky
Copy link
Contributor Author

whtsky commented Mar 8, 2018

In fact .persist() is the important part.
I'm using Ant Design with formit using TypeScript. Ant Design declare a lot of event as SyntheticEvent but in fact are not, which causes a lot of trouble.
jaredpalmer/formik#187

@yesmeck
Copy link
Member

yesmeck commented Mar 8, 2018

We can not change the API for now, as @Spoki4 mentioned in jaredpalmer/formik#187 you'd have to wrap onChange by yourself or use setFieldValue instead.

@yesmeck yesmeck closed this as completed Mar 8, 2018
@whtsky
Copy link
Contributor Author

whtsky commented Mar 8, 2018

IMO it's a bug since the typing info provided by Ant Design is wrong, so I suggest leave the issue open until the typing got corrected?

@yesmeck
Copy link
Member

yesmeck commented Mar 8, 2018

@whtsky Fixing.

yesmeck added a commit that referenced this issue Mar 8, 2018
afc163 pushed a commit that referenced this issue Mar 10, 2018
* Add the defaultActiveTabKey property for the Card component (close #8789, #8942)

* `activeTabKey` should be added

* Improve

* Fix large tabs font size, close #9509

* docs: Add TreeSelect[dropdownClassName]

* Fix passing dropdownClassName to tree-select

* build: update remark-parse requirement to ^5.0.0 (#9545)

Updates the requirements on [remark-parse](https://github.com/remarkjs/remark) to permit the latest version.
- [Release notes](https://github.com/remarkjs/remark/releases)
- [Commits](https://github.com/remarkjs/remark/commits/remark@5.0.0)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* add Tooltip  contextMenu doc

* Improve Grid and Layout type definition

* fix: focus editor (#9548)

* Fix test case for new jsdom (#9527)

* Fix test case for new jsdom

* use setTimeout as raf in jest jsdom

* Fix cancelAnimationFrame

* Add comment for jestjs/jest#5147

* longer timeout

* fix snap

* upgrade antd-tools

* Update typescript requirement to ~2.7.2 (#9522)

Updates the requirements on [typescript](https://github.com/Microsoft/TypeScript) to permit the latest version.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/commits/v2.7.2)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Fix a ts error

* build: update react-slick requirement to ~0.20.0 (#9543)

Updates the requirements on [react-slick](https://github.com/akiran/react-slick) to permit the latest version.
- [Changelog](https://github.com/akiran/react-slick/blob/master/CHANGELOG.md)
- [Commits](https://github.com/akiran/react-slick/commits)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* Fix test cases

* site: fix intersection-observer polyfill

* docs: update recommendation

* Fix typo WeexPickerProps -> WeekPickerProps (#9564)

* use lodash

* Fixed typo on Visualization rules (#9575)

Style of a navigation should conform to the its level.

should be

Style of a navigation should conform to its level.

* Improve Radio/Checkbox type definition

Close #9574

* Remove AbstractCheckboxChangeEvent, fix TS4029 error

See microsoft/TypeScript#9944

* Update index.en-US.md (#9579)

* add transitionName from message.config (#9580)

* add transitionName from message.config

* Update index.en-US.md (#9579)

* modify doc

* build: update react-virtualized requirement to ~9.18.5 (#9544)

Updates the requirements on [react-virtualized](https://github.com/bvaughn/react-virtualized) to permit the latest version.
- [Changelog](https://github.com/bvaughn/react-virtualized/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bvaughn/react-virtualized/commits/9.18.5)

Signed-off-by: dependabot[bot] <support@dependabot.com>

* When treeNode is disabled, its switcher is highlight and clickabled (#9539)

* When treeNode is disabled, its switcher is highlight and clickabled

* rc-tree@1.7.11

* Fix moment require (#9528)

Fix #9502

* Update snapshot
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

No branches or pull requests

5 participants