From 6a8d7e4ed3ec4dc778374c84dffdd048215b64e5 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 19 Nov 2022 15:26:07 -0600 Subject: [PATCH] StopPropagation: let it be disabled --- app/soapbox/components/stop-propagation.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/soapbox/components/stop-propagation.tsx b/app/soapbox/components/stop-propagation.tsx index 614fa129c..f8eff7b4e 100644 --- a/app/soapbox/components/stop-propagation.tsx +++ b/app/soapbox/components/stop-propagation.tsx @@ -1,7 +1,10 @@ import React from 'react'; interface IStopPropagation { + /** Children to render within the bubble. */ children: React.ReactNode, + /** Whether to prevent mouse events from bubbling. (default: `true`) */ + enabled?: boolean, } /** @@ -11,10 +14,12 @@ interface IStopPropagation { * To prevent a lot of code duplication, this component can stop all mouse events. * Plus, placing it in the component tree makes it more readable. */ -const StopPropagation: React.FC = ({ children }) => { +const StopPropagation: React.FC = ({ children, enabled = true }) => { const handler: React.MouseEventHandler = (e) => { - e.stopPropagation(); + if (enabled) { + e.stopPropagation(); + } }; return (