Skip to content

Commit d48e48b

Browse files
committed
walk back potential breaking change and just use the new pattern hooray
1 parent a6ab17a commit d48e48b

File tree

4 files changed

+13
-8
lines changed

4 files changed

+13
-8
lines changed

.changeset/chilly-months-win.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.changeset/red-dingos-know.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"react-medium-image-zoom": minor
33
---
44

5-
Add support for onZoomChange reporting to Uncontrolled components and include additional argument housing the fired event information
5+
Add support for onZoomChange reporting to Uncontrolled components and include additional argument housing the fired event

source/Controlled.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ class ControlledBase extends React.Component<ControlledPropsWithDefaults, Contro
529529
*/
530530
handleZoom = (e: React.SyntheticEvent | Event) => {
531531
if (!this.props.isDisabled && this.hasImage()) {
532-
e.stopPropagation()
533532
this.props.onZoomChange?.(true, { event: e })
534533
}
535534
}

stories/Img.stories.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,17 @@ function CardItem({
787787
setIsSelected(e.currentTarget.checked)
788788
}, [])
789789

790+
const handleZoomChange = React.useCallback<
791+
NonNullable<React.ComponentProps<typeof Zoom>['onZoomChange']>
792+
>((value, { event }) => {
793+
event.stopPropagation()
794+
795+
console.log(
796+
'handleZoomChange (after event.stopPropagation())',
797+
{ value, event }
798+
)
799+
}, [])
800+
790801
return (
791802
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
792803
<li className="card" onClick={handleItemClick}>
@@ -799,7 +810,7 @@ function CardItem({
799810
type="checkbox"
800811
/>
801812
</label>
802-
<Zoom {...zoomProps} wrapElement="span">
813+
<Zoom {...zoomProps} onZoomChange={handleZoomChange} wrapElement="span">
803814
<img
804815
alt={alt}
805816
src={src}

0 commit comments

Comments
 (0)