-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fixed: Web - Desktop Attachments - Cannot attach a photo when the NEW ( green plus) button is pressed #9021
Changes from 4 commits
a5bb991
7573440
c06b304
842b0a7
c221851
dc06bce
c853e4b
e48d2f9
1584251
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,26 +5,33 @@ import {View} from 'react-native'; | |
import {withOnyx} from 'react-native-onyx'; | ||
import PropTypes from 'prop-types'; | ||
import {withNavigation} from '@react-navigation/compat'; | ||
import styles from '../../../styles/styles'; | ||
import SidebarLinks from './SidebarLinks'; | ||
import PopoverMenu from '../../../components/PopoverMenu'; | ||
import FAB from '../../../components/FAB'; | ||
import ScreenWrapper from '../../../components/ScreenWrapper'; | ||
import Navigation from '../../../libs/Navigation/Navigation'; | ||
import ROUTES from '../../../ROUTES'; | ||
import Timing from '../../../libs/actions/Timing'; | ||
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions'; | ||
import CONST from '../../../CONST'; | ||
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize'; | ||
import compose from '../../../libs/compose'; | ||
import * as Expensicons from '../../../components/Icon/Expensicons'; | ||
import Permissions from '../../../libs/Permissions'; | ||
import ONYXKEYS from '../../../ONYXKEYS'; | ||
import * as Policy from '../../../libs/actions/Policy'; | ||
import Performance from '../../../libs/Performance'; | ||
import * as Welcome from '../../../libs/actions/Welcome'; | ||
import styles from '../../../../styles/styles'; | ||
import SidebarLinks from '../SidebarLinks'; | ||
import PopoverMenu from '../../../../components/PopoverMenu'; | ||
import FAB from '../../../../components/FAB'; | ||
import ScreenWrapper from '../../../../components/ScreenWrapper'; | ||
import Navigation from '../../../../libs/Navigation/Navigation'; | ||
import ROUTES from '../../../../ROUTES'; | ||
import Timing from '../../../../libs/actions/Timing'; | ||
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../../components/withWindowDimensions'; | ||
import CONST from '../../../../CONST'; | ||
import withLocalize, {withLocalizePropTypes} from '../../../../components/withLocalize'; | ||
import compose from '../../../../libs/compose'; | ||
import * as Expensicons from '../../../../components/Icon/Expensicons'; | ||
import Permissions from '../../../../libs/Permissions'; | ||
import ONYXKEYS from '../../../../ONYXKEYS'; | ||
import * as Policy from '../../../../libs/actions/Policy'; | ||
import Performance from '../../../../libs/Performance'; | ||
import * as Welcome from '../../../../libs/actions/Welcome'; | ||
|
||
const propTypes = { | ||
|
||
/* Create Listener callback */ | ||
onShowCreateMenu: PropTypes.func, | ||
|
||
/* Remove Listener callback */ | ||
onHideCreateMenu: PropTypes.func, | ||
|
||
/* Beta features list */ | ||
betas: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can come from the |
||
|
||
|
@@ -36,10 +43,12 @@ const propTypes = { | |
...withLocalizePropTypes, | ||
}; | ||
const defaultProps = { | ||
onHideCreateMenu: () => {}, | ||
onShowCreateMenu: () => {}, | ||
isCreatingWorkspace: false, | ||
}; | ||
|
||
class SidebarScreen extends Component { | ||
class BaseSidebarScreen extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
|
@@ -59,6 +68,9 @@ class SidebarScreen extends Component { | |
|
||
const routes = lodashGet(this.props.navigation.getState(), 'routes', []); | ||
Welcome.show({routes, showCreateMenu: this.showCreateMenu}); | ||
if (this.props.innerRef) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need the |
||
this.props.innerRef.current = this; | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -68,6 +80,7 @@ class SidebarScreen extends Component { | |
this.setState({ | ||
isCreateMenuActive: true, | ||
}); | ||
this.props.onShowCreateMenu(); | ||
} | ||
|
||
/** | ||
|
@@ -83,6 +96,7 @@ class SidebarScreen extends Component { | |
* Selecting an item on CreateMenu or closing it by clicking outside of the modal component | ||
*/ | ||
hideCreateMenu() { | ||
this.props.onHideCreateMenu(); | ||
this.setState({ | ||
isCreateMenuActive: false, | ||
}); | ||
|
@@ -184,8 +198,8 @@ class SidebarScreen extends Component { | |
} | ||
} | ||
|
||
SidebarScreen.propTypes = propTypes; | ||
SidebarScreen.defaultProps = defaultProps; | ||
BaseSidebarScreen.propTypes = propTypes; | ||
BaseSidebarScreen.defaultProps = defaultProps; | ||
|
||
export default compose( | ||
withNavigation, | ||
|
@@ -202,4 +216,4 @@ export default compose( | |
key: ONYXKEYS.IS_CREATING_WORKSPACE, | ||
}, | ||
}), | ||
)(SidebarScreen); | ||
)(BaseSidebarScreen); |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,29 @@ | ||||||
import React, {useRef} from 'react'; | ||||||
import BaseSidebarScreen from './BaseSidebarScreen'; | ||||||
|
||||||
export default function (props) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Name the function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am very embarrassed for the mistake I made. Please accept my apology :( . There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries. Happens with the best of us. |
||||||
const BaseSidebarScreenRef = useRef(null); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
/** | ||||||
* Method create event listener | ||||||
*/ | ||||||
const createDragoverListener = () => { | ||||||
document.addEventListener('dragover', BaseSidebarScreenRef.current.hideCreateMenu); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
|
||||||
/** | ||||||
* Method remove event listener. | ||||||
*/ | ||||||
const removeDragoverListener = () => { | ||||||
document.removeEventListener('dragover', BaseSidebarScreenRef.current.hideCreateMenu); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
return ( | ||||||
<BaseSidebarScreen | ||||||
innerRef={BaseSidebarScreenRef} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
onShowCreateMenu={createDragoverListener} | ||||||
onHideCreateMenu={removeDragoverListener} | ||||||
// eslint-disable-next-line react/jsx-props-no-spreading | ||||||
{...props} | ||||||
/> | ||||||
); | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react'; | ||
import BaseSidebarScreen from './BaseSidebarScreen'; | ||
|
||
export default function SidebarScreen(props) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I add propTypes I had to add this lines (for warnings) so that the required fields come . But I removed it from baseSidebarScreen. export default compose(
withNavigation,
withLocalize,
withWindowDimensions,
withOnyx({
allPolicies: {
key: ONYXKEYS.COLLECTION.POLICY,
},
betas: {
key: ONYXKEYS.BETAS,
},
isCreatingWorkspace: {
key: ONYXKEYS.IS_CREATING_WORKSPACE,
},
}),
)(SidebarScreen); |
||
// eslint-disable-next-line react/jsx-props-no-spreading | ||
return <BaseSidebarScreen {...props} />; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be more descriptive