Skip to content

Commit

Permalink
fix: passive event warning on mobile (#7484)
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo authored Mar 23, 2023
1 parent be28f5d commit 5af9ad8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
8 changes: 8 additions & 0 deletions .changeset/fast-cherries-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@chakra-ui/radio": patch
---

- Fix issue where shows console warning due to `preventDefault` call in pointer
event on mobile

- Add deprecation warning for `getCheckboxProps` in favor of `getRadioProps`
6 changes: 6 additions & 0 deletions .changeset/modern-ads-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@chakra-ui/checkbox": patch
---

Fix issue where shows console warning due to `preventDefault` call in pointer
event on mobile
1 change: 0 additions & 1 deletion packages/components/checkbox/src/use-checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ export function useCheckbox(props: UseCheckboxProps = {}) {
...props,
ref: forwardedRef,
onMouseDown: callAllHandlers(props.onMouseDown, stopEvent),
onTouchStart: callAllHandlers(props.onTouchStart, stopEvent),
"data-disabled": dataAttr(isDisabled),
"data-checked": dataAttr(isChecked),
"data-invalid": dataAttr(isInvalid),
Expand Down
10 changes: 6 additions & 4 deletions packages/components/radio/src/use-radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,7 @@ export function useRadio(props: UseRadioProps = {}) {
const getLabelProps: PropGetter = (props = {}, ref = null) => ({
...props,
ref,
onMouseDown: callAllHandlers(props.onMouseDown, stop),
onTouchStart: callAllHandlers(props.onTouchStart, stop),
onMouseDown: callAllHandlers(props.onMouseDown, stopEvent),
"data-disabled": dataAttr(isDisabled),
"data-checked": dataAttr(isChecked),
"data-invalid": dataAttr(isInvalid),
Expand All @@ -300,8 +299,11 @@ export function useRadio(props: UseRadioProps = {}) {

return {
state,
// the function is renamed to getRadioProps to make the code more consistent. It is renamed towards outside because otherwise this would produce a breaking change
/**
* @deprecated - use `getRadioProps` instead
*/
getCheckboxProps: getRadioProps,
getRadioProps,
getInputProps,
getLabelProps,
getRootProps,
Expand All @@ -312,7 +314,7 @@ export function useRadio(props: UseRadioProps = {}) {
/**
* Prevent `onBlur` being fired when the radio label is touched
*/
function stop(event: React.SyntheticEvent) {
function stopEvent(event: React.SyntheticEvent) {
event.preventDefault()
event.stopPropagation()
}
Expand Down

1 comment on commit 5af9ad8

@vercel
Copy link

@vercel vercel bot commented on 5af9ad8 Mar 23, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.