From 3ebe56a37a9a172fca57cad6d8fc0740abe4c2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ella=20van=C2=A0Durpe?= Date: Tue, 4 May 2021 14:06:40 +0300 Subject: [PATCH] Fix scrolling div --- .../src/components/visual-editor/index.js | 87 +++++++++---------- 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/packages/edit-post/src/components/visual-editor/index.js b/packages/edit-post/src/components/visual-editor/index.js index fd36102c97855..5d73016570c2a 100644 --- a/packages/edit-post/src/components/visual-editor/index.js +++ b/packages/edit-post/src/components/visual-editor/index.js @@ -28,6 +28,7 @@ import { __unstableUseMouseMoveTypingReset as useMouseMoveTypingReset, __unstableIframe as Iframe, } from '@wordpress/block-editor'; +import { useRef } from '@wordpress/element'; import { Popover, Button } from '@wordpress/components'; import { useSelect, useDispatch } from '@wordpress/data'; import { useMergeRefs, useRefEffect } from '@wordpress/compose'; @@ -131,7 +132,9 @@ export default function VisualEditor( { styles } ) { paddingBottom = '40vh'; } + const ref = useRef(); const contentRef = useMergeRefs( [ + ref, useClipboardHandler(), useCanvasClickRedirect(), useTypewriter(), @@ -146,11 +149,11 @@ export default function VisualEditor( { styles } ) { // because it will bubble through portals. const toolWrapperRef = useRefEffect( ( node ) => { function onWheel( { deltaX, deltaY } ) { - contentRef.current.scrollBy( deltaX, deltaY ); + ref.current.scrollBy( deltaX, deltaY ); } node.addEventListener( 'wheel', onWheel ); return () => { - node.addEventListener( 'wheel', onWheel ); + node.removeEventListener( 'wheel', onWheel ); }; }, [] ); @@ -181,52 +184,48 @@ export default function VisualEditor( { styles } ) { { __( 'Back' ) } ) } -
- - - - - - { ! isTemplateMode && ( -
- -
- ) } - -
-
-
-
-
-
+ + + + { ! isTemplateMode && ( +
+ +
+ ) } + +
+
+
+ + <__experimentalBlockSettingsMenuFirstItem> { ( { onClose } ) => (