Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable Drag & Drop by default #24536

Merged
merged 12 commits into from
Aug 22, 2023
21 changes: 20 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import '../wdyr';
import React from 'react';
import React, {useEffect} from 'react';
import {LogBox} from 'react-native';
import {GestureHandlerRootView} from 'react-native-gesture-handler';
import {SafeAreaProvider} from 'react-native-safe-area-context';
Expand All @@ -23,6 +23,8 @@ import ThemeStylesProvider from './styles/ThemeStylesProvider';
import {CurrentReportIDContextProvider} from './components/withCurrentReportID';
import {EnvironmentProvider} from './components/withEnvironment';
import * as Session from './libs/actions/Session';
import getPlatform from './libs/getPlatform';
import CONST from './CONST';

// For easier debugging and development, when we are in web we expose Onyx to the window, so you can more easily set data into Onyx
if (window && Environment.isDevelopment()) {
Expand All @@ -40,6 +42,23 @@ LogBox.ignoreLogs([
const fill = {flex: 1};

function App() {
const dropDragListener = (event) => {
event.preventDefault();
// eslint-disable-next-line no-param-reassign
event.dataTransfer.dropEffect = 'none';
};

useEffect(() => {
const platform = getPlatform();
if (platform !== CONST.PLATFORM.WEB && platform !== CONST.PLATFORM.DESKTOP) {
return;
}
document.addEventListener('dragover', dropDragListener);
document.addEventListener('dragenter', dropDragListener);
document.addEventListener('dragleave', dropDragListener);
document.addEventListener('drop', dropDragListener);
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We never use platform specific code inline like this @ginsuma. Please create separate files for each platform.


return (
<GestureHandlerRootView style={fill}>
<ComposeProviders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ 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 */
Expand Down Expand Up @@ -53,28 +52,26 @@ function ThreePaneView(props) {
);
}
if (route.name === NAVIGATORS.RIGHT_MODAL_NAVIGATOR) {
const Wrapper = props.state.index === i ? NoDropZone : React.Fragment;
return (
<Wrapper key={route.key}>
<View
style={[
styles.flexRow,
styles.pAbsolute,
styles.w100,
styles.h100,
StyleUtils.getBackgroundColorWithOpacityStyle(themeColors.shadow, CONST.RIGHT_MODAL_BACKGROUND_OVERLAY_OPACITY),
StyleUtils.displayIfTrue(props.state.index === i),
]}
>
<PressableWithoutFeedback
style={[styles.flex1]}
onPress={() => props.navigation.goBack()}
accessibilityLabel={translate('common.close')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
/>
<View style={styles.rightPanelContainer}>{props.descriptors[route.key].render()}</View>
</View>
</Wrapper>
<View
key={route.key}
style={[
styles.flexRow,
styles.pAbsolute,
styles.w100,
styles.h100,
StyleUtils.getBackgroundColorWithOpacityStyle(themeColors.shadow, CONST.RIGHT_MODAL_BACKGROUND_OVERLAY_OPACITY),
StyleUtils.displayIfTrue(props.state.index === i),
]}
>
<PressableWithoutFeedback
style={[styles.flex1]}
onPress={() => props.navigation.goBack()}
accessibilityLabel={translate('common.close')}
accessibilityRole={CONST.ACCESSIBILITY_ROLE.BUTTON}
/>
<View style={styles.rightPanelContainer}>{props.descriptors[route.key].render()}</View>
</View>
);
}
return (
Expand Down
Loading