diff --git a/src/components/DragAndDrop/NoDropZone/index.js b/src/components/DragAndDrop/NoDropZone/index.js new file mode 100644 index 000000000000..f562796ce09a --- /dev/null +++ b/src/components/DragAndDrop/NoDropZone/index.js @@ -0,0 +1,32 @@ +import {useEffect} from 'react'; +import PropTypes from 'prop-types'; + +const propTypes = { + /** Content */ + children: PropTypes.node.isRequired, +}; + +function NoDropZone(props) { + function handleDrag(event) { + event.preventDefault(); + // eslint-disable-next-line no-param-reassign + event.dataTransfer.dropEffect = 'none'; + } + + useEffect(() => { + document.addEventListener('dragenter', handleDrag); + document.addEventListener('dragover', handleDrag); + + return () => { + document.removeEventListener('dragenter', handleDrag); + document.removeEventListener('dragover', handleDrag); + }; + }, []); + + return props.children; +} + +NoDropZone.displayName = 'NoDropZone'; +NoDropZone.propTypes = propTypes; + +export default NoDropZone; diff --git a/src/components/DragAndDrop/NoDropZone/index.native.js b/src/components/DragAndDrop/NoDropZone/index.native.js new file mode 100644 index 000000000000..c091ce4b6597 --- /dev/null +++ b/src/components/DragAndDrop/NoDropZone/index.native.js @@ -0,0 +1,5 @@ +const NoDropZone = (props) => props.children; + +NoDropZone.displayName = 'NoDropZone'; + +export default NoDropZone; diff --git a/src/libs/Navigation/AppNavigator/createResponsiveStackNavigator/ThreePaneView.js b/src/libs/Navigation/AppNavigator/createResponsiveStackNavigator/ThreePaneView.js index 75a5a1f514f7..afa075bcb550 100644 --- a/src/libs/Navigation/AppNavigator/createResponsiveStackNavigator/ThreePaneView.js +++ b/src/libs/Navigation/AppNavigator/createResponsiveStackNavigator/ThreePaneView.js @@ -11,6 +11,7 @@ import styles from '../../../../styles/styles'; import CONST from '../../../../CONST'; import PressableWithoutFeedback from '../../../../components/Pressable/PressableWithoutFeedback'; import useLocalize from '../../../../hooks/useLocalize'; +import NoDropZone from '../../../../components/DragAndDrop/NoDropZone'; const propTypes = { /* State from useNavigationBuilder */ @@ -53,25 +54,26 @@ function ThreePaneView(props) { } if (route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) { return ( - - props.navigation.goBack()} - accessibilityLabel={translate('common.close')} - accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} - /> - {props.descriptors[route.key].render()} - + + + props.navigation.goBack()} + accessibilityLabel={translate('common.close')} + accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON} + /> + {props.descriptors[route.key].render()} + + ); } return (