From 6a74ad94f6a76ac2377e70f1f3f40ed4992a8573 Mon Sep 17 00:00:00 2001 From: Brokyeom Date: Sun, 24 Nov 2024 01:11:41 +0900 Subject: [PATCH 1/6] fix: Adjust BubbleInput position in Switch - Fixed the issue where BubbleInput was positioned incorrectly - Adjusted positioning by wrapping with a div to align the Input within the Button area --- packages/react/switch/src/Switch.tsx | 67 +++++++++++++--------------- 1 file changed, 31 insertions(+), 36 deletions(-) diff --git a/packages/react/switch/src/Switch.tsx b/packages/react/switch/src/Switch.tsx index 96ab46753..56c65c05d 100644 --- a/packages/react/switch/src/Switch.tsx +++ b/packages/react/switch/src/Switch.tsx @@ -57,44 +57,39 @@ const Switch = React.forwardRef( return ( - { - setChecked((prevChecked) => !prevChecked); - if (isFormControl) { - hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); - // if switch is in a form, stop propagation from the button so that we only propagate - // one click event (from the input). We propagate changes from an input so that native - // form validation works and form events reflect switch updates. - if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation(); - } - })} - /> - {isFormControl && ( - + { + setChecked((prevChecked) => !prevChecked); + if (isFormControl) { + hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); + if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation(); + } + })} /> - )} + {isFormControl && ( + + )} + ); } From a8cfddfae46068e244e8b53b384f36b55824f9f7 Mon Sep 17 00:00:00 2001 From: Brokyeom Date: Sun, 24 Nov 2024 01:12:22 +0900 Subject: [PATCH 2/6] patch release. --- .yarn/versions/9b826bac.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .yarn/versions/9b826bac.yml diff --git a/.yarn/versions/9b826bac.yml b/.yarn/versions/9b826bac.yml new file mode 100644 index 000000000..134a2abe4 --- /dev/null +++ b/.yarn/versions/9b826bac.yml @@ -0,0 +1,2 @@ +releases: + "@radix-ui/react-switch": patch From b4068d661507a7c058128bdf99e1f3d8d3494a0c Mon Sep 17 00:00:00 2001 From: Brokyeom Date: Sun, 24 Nov 2024 01:13:00 +0900 Subject: [PATCH 3/6] decline release. --- .yarn/versions/9b826bac.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.yarn/versions/9b826bac.yml b/.yarn/versions/9b826bac.yml index 134a2abe4..31ac9fbfb 100644 --- a/.yarn/versions/9b826bac.yml +++ b/.yarn/versions/9b826bac.yml @@ -1,2 +1,5 @@ releases: "@radix-ui/react-switch": patch + +declined: + - primitives From 837c9a184db4db265e8c06384615cc6c57270e02 Mon Sep 17 00:00:00 2001 From: Brokyeom Date: Sun, 24 Nov 2024 14:38:54 +0900 Subject: [PATCH 4/6] restore annotation --- packages/react/switch/src/Switch.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/react/switch/src/Switch.tsx b/packages/react/switch/src/Switch.tsx index 56c65c05d..3c09e0b7c 100644 --- a/packages/react/switch/src/Switch.tsx +++ b/packages/react/switch/src/Switch.tsx @@ -73,6 +73,9 @@ const Switch = React.forwardRef( setChecked((prevChecked) => !prevChecked); if (isFormControl) { hasConsumerStoppedPropagationRef.current = event.isPropagationStopped(); + // if switch is in a form, stop propagation from the button so that we only propagate + // one click event (from the input). We propagate changes from an input so that native + // form validation works and form events reflect switch updates. if (!hasConsumerStoppedPropagationRef.current) event.stopPropagation(); } })} From eebf306546826a0bccc4289d38d4b502b2834ed7 Mon Sep 17 00:00:00 2001 From: Brokyeom Date: Sun, 24 Nov 2024 14:59:04 +0900 Subject: [PATCH 5/6] Add comment. --- packages/react/switch/src/Switch.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/react/switch/src/Switch.tsx b/packages/react/switch/src/Switch.tsx index 3c09e0b7c..b65a1303c 100644 --- a/packages/react/switch/src/Switch.tsx +++ b/packages/react/switch/src/Switch.tsx @@ -57,6 +57,10 @@ const Switch = React.forwardRef( return ( + {/* + Wrap with div to prevent input from escaping component bounds + link : https://github.com/radix-ui/primitives/issues/3235 + */}
Date: Sun, 24 Nov 2024 15:37:42 +0900 Subject: [PATCH 6/6] Remove link --- packages/react/switch/src/Switch.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/react/switch/src/Switch.tsx b/packages/react/switch/src/Switch.tsx index b65a1303c..1707674a7 100644 --- a/packages/react/switch/src/Switch.tsx +++ b/packages/react/switch/src/Switch.tsx @@ -59,7 +59,6 @@ const Switch = React.forwardRef( {/* Wrap with div to prevent input from escaping component bounds - link : https://github.com/radix-ui/primitives/issues/3235 */}