File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
src/frontend/apps/impress/src/features/docs Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import { css } from 'styled-components';
1212
1313import { Box , Overlayer , StyledLink } from '@/components' ;
1414import { useCunninghamTheme } from '@/cunningham' ;
15- import { Doc , SimpleDocItem } from '@/docs/doc-management' ;
15+ import { Doc , SimpleDocItem , useTrans } from '@/docs/doc-management' ;
1616
1717import { KEY_DOC_TREE , useDocTree } from '../api/useDocTree' ;
1818import { useMoveDoc } from '../api/useMove' ;
Original file line number Diff line number Diff line change 11import { Data , useDraggable } from '@dnd-kit/core' ;
2+ import { useEffect , useState } from 'react' ;
23
34type DraggableProps < T > = {
45 id : string ;
@@ -7,11 +8,44 @@ type DraggableProps<T> = {
78} ;
89
910export const Draggable = < T , > ( props : DraggableProps < T > ) => {
11+ const [ isDisabled , setIsDisabled ] = useState ( false ) ;
12+
1013 const { attributes, listeners, setNodeRef } = useDraggable ( {
1114 id : props . id ,
1215 data : props . data ,
16+ disabled : isDisabled ,
1317 } ) ;
1418
19+ useEffect ( ( ) => {
20+ const checkModal = ( ) => {
21+ const modalOpen = document . querySelector ( '[role="dialog"]' ) ;
22+ setIsDisabled ( ! ! modalOpen ) ;
23+ } ;
24+
25+ checkModal ( ) ;
26+
27+ const observer = new MutationObserver ( checkModal ) ;
28+ observer . observe ( document . body , {
29+ childList : true ,
30+ subtree : true ,
31+ } ) ;
32+
33+ return ( ) => observer . disconnect ( ) ;
34+ } , [ ] ) ;
35+
36+ if ( isDisabled ) {
37+ return (
38+ < div
39+ data-testid = { `draggable-doc-${ props . id } ` }
40+ className = "--docs--grid-draggable --disabled"
41+ role = "none"
42+ style = { { pointerEvents : 'none' } }
43+ >
44+ { props . children }
45+ </ div >
46+ ) ;
47+ }
48+
1549 return (
1650 < div
1751 ref = { setNodeRef }
Original file line number Diff line number Diff line change @@ -62,7 +62,7 @@ export const DocImportModal = ({
6262 aria-label = { t ( 'Cancel the move' ) }
6363 variant = "secondary"
6464 fullWidth
65- // onClick={() => onClose() }
65+ onClick = { onClose }
6666 >
6767 { t ( 'Cancel' ) }
6868 </ Button >
@@ -115,6 +115,10 @@ export const DocImportModal = ({
115115 $direction = "column"
116116 $justify = "space-between"
117117 className = "--docs--doc-move-modal"
118+ onKeyDown = { ( e ) => {
119+ // Prevent keyboard events from bubbling to parent components (e.g., drag and drop)
120+ e . stopPropagation ( ) ;
121+ } }
118122 >
119123 < QuickSearch
120124 placeholder = { t ( 'Search for a doc' ) }
You can’t perform that action at this time.
0 commit comments