1- import type { CSSProperties , HTMLAttributes , ReactNode } from "react" ;
1+ import type { HTMLAttributes , ReactNode } from "react" ;
22
33type InteractiveContainerProps = {
44 children : ReactNode ;
5- className ?: string ;
6- style ?: CSSProperties ;
75} & HTMLAttributes < HTMLDivElement > ;
86
97const handleContainerWheel = ( evt : Event ) => {
@@ -16,19 +14,10 @@ const handleContainerWheel = (evt: Event) => {
1614 }
1715} ;
1816
19- const attachMainHandler = ( target : Node ) => {
17+ const attachMainHandler = ( target : Node | null ) => {
2018 const o = { capture : false , passive : false , once : false } ;
21- target . removeEventListener ( "wheel" , handleContainerWheel , o ) ;
22- target . addEventListener ( "wheel" , handleContainerWheel , o ) ;
23- } ;
24-
25- const weakSet = new WeakSet ( ) ;
26-
27- const setRef = ( div : HTMLDivElement ) => {
28- if ( ! div ) return ;
29- if ( weakSet . has ( div ) ) return ;
30- weakSet . add ( div ) ;
31- attachMainHandler ( div ) ;
19+ target ?. removeEventListener ( "wheel" , handleContainerWheel , o ) ;
20+ target ?. addEventListener ( "wheel" , handleContainerWheel , o ) ;
3221} ;
3322
3423/**
@@ -41,17 +30,7 @@ const setRef = (div: HTMLDivElement) => {
4130 * - Outside Monaco, stop propagation so parent/page-level handlers do not
4231 * react to wheel gestures from this container.
4332 */
44- export default function InteractiveContainer ( { children, className, style, ...props } : InteractiveContainerProps ) {
45- return (
46- < div
47- { ...props }
48- className = { [ "interactive-container" , className ] . filter ( Boolean ) . join ( " " ) }
49- style = { {
50- ...style ,
51- } }
52- ref = { setRef }
53- >
54- { children }
55- </ div >
56- ) ;
33+ export default function InteractiveContainer ( { children } : InteractiveContainerProps ) {
34+ attachMainHandler ( document . getElementById ( "root" ) ) ;
35+ return < > { children } </ > ;
5736}
0 commit comments