-
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
prevent FAB menu and other page showing simultaneously #12655
Changes from 1 commit
1ddcbbe
e6c6305
fc227dd
2e614d9
b8f6762
f20e5aa
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 | ||||
---|---|---|---|---|---|---|
|
@@ -84,9 +84,22 @@ const defaultProps = { | |||||
|
||||||
class SidebarLinks extends React.Component { | ||||||
showSearchPage() { | ||||||
if (this.props.isMenuOpen) { | ||||||
// Prevent opening Search page when click Search icon quickly after clicking FAB icon | ||||||
return; | ||||||
} | ||||||
Navigation.navigate(ROUTES.SEARCH); | ||||||
} | ||||||
|
||||||
showReportPage(reportID) { | ||||||
if (this.props.isMenuOpen) { | ||||||
// Prevent opening Report page when click LHN row quickly after clicking FAB icon | ||||||
return; | ||||||
} | ||||||
Navigation.navigate(ROUTES.getReportRoute(reportID)); | ||||||
this.props.onLinkClick(); | ||||||
} | ||||||
|
||||||
render() { | ||||||
// Wait until the personalDetails are actually loaded before displaying the LHN | ||||||
if (_.isEmpty(this.props.personalDetails)) { | ||||||
|
@@ -121,7 +134,7 @@ class SidebarLinks extends React.Component { | |||||
accessibilityLabel={this.props.translate('sidebarScreen.buttonSearch')} | ||||||
accessibilityRole="button" | ||||||
style={[styles.flexRow, styles.ph5]} | ||||||
onPress={this.showSearchPage} | ||||||
onPress={() => this.showSearchPage()} | ||||||
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. Revert it please.
Suggested change
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 did this because 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. Bind it and use it. |
||||||
> | ||||||
<Icon src={Expensicons.MagnifyingGlass} /> | ||||||
</TouchableOpacity> | ||||||
|
@@ -147,10 +160,7 @@ class SidebarLinks extends React.Component { | |||||
focusedIndex={_.findIndex(optionListItems, ( | ||||||
option => option.toString() === this.props.reportIDFromRoute | ||||||
))} | ||||||
onSelectRow={(option) => { | ||||||
Navigation.navigate(ROUTES.getReportRoute(option.reportID)); | ||||||
this.props.onLinkClick(); | ||||||
}} | ||||||
onSelectRow={option => this.showReportPage(option.reportID)} | ||||||
shouldDisableFocusOptions={this.props.isSmallScreenWidth} | ||||||
optionMode={this.props.priorityMode === CONST.PRIORITY_MODE.GSD ? 'compact' : 'default'} | ||||||
onLayout={App.setSidebarLoaded} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -19,6 +19,7 @@ import Performance from '../../../../libs/Performance'; | |||||
import * as Welcome from '../../../../libs/actions/Welcome'; | ||||||
import {sidebarPropTypes, sidebarDefaultProps} from './sidebarPropTypes'; | ||||||
import withDrawerState from '../../../../components/withDrawerState'; | ||||||
import withNavigationFocus from '../../../../components/withNavigationFocus'; | ||||||
import KeyboardShortcutsModal from '../../../../components/KeyboardShortcutsModal'; | ||||||
|
||||||
const propTypes = { | ||||||
|
@@ -62,10 +63,51 @@ class BaseSidebarScreen extends Component { | |||||
Welcome.show({routes, showCreateMenu: this.showCreateMenu}); | ||||||
} | ||||||
|
||||||
componentDidUpdate(prevProps) { | ||||||
if (!this.didBecomeInactive(prevProps)) { | ||||||
return; | ||||||
} | ||||||
|
||||||
// Hide menu manually when other pages are opened using shortcut key | ||||||
this.hideCreateMenu(); | ||||||
} | ||||||
|
||||||
didBecomeInactive(prevProps) { | ||||||
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. Same for it. A better name is needed. Functions are named on what they do not where they are called. 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. Maybe better to name 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. @Beamanator thoughts? I am not good with name.. 🐈 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. Honestly I'd rather not negate a negative - we're checking if the outcome of this function is false ( So how about this name: 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 think 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. Opposite of
|
||||||
// When Report page is just opened | ||||||
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
|
||||||
if (!this.props.isDrawerOpen && prevProps.isDrawerOpen) { | ||||||
return true; | ||||||
} | ||||||
|
||||||
// When other page is just opened | ||||||
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
|
||||||
if (!this.props.isFocused && prevProps.isFocused) { | ||||||
return true; | ||||||
} | ||||||
|
||||||
return false; | ||||||
} | ||||||
|
||||||
isInactive() { | ||||||
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. is Inactive what? Can we think of a better name? Functions are named on what they do not where they are called. 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. Is this component (BaseSidebarScreen) inactive? Meaning screen is blurred because of other pages open 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. cc: @Beamanator 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. Agreed, what about 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. Screen is actually not hidden on web. just blurred by another modal |
||||||
// When drawer is closed and Report page is open | ||||||
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. What is difference between didBecomeInactive and this funciton. Why can't we use didBecomeInactive after combining those? 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.
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. Ok 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 JSDocs for both functions with details. 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. @aimane-chnaif Can you please do this? 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. @parasharrajat I think it's done in latest commit. What's missing? 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. Comments for functions. There is no details about these functions and how they are used. 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. please check now |
||||||
if (this.props.isSmallScreenWidth && !this.props.isDrawerOpen) { | ||||||
return true; | ||||||
} | ||||||
|
||||||
// When other page is open | ||||||
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 returns true if any other page is open? Or a specific page? Let's be a bit clearer here 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. correct. any other page is open except Report (this is handled with 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. Cool so how about this
Suggested change
|
||||||
if (!this.props.isFocused) { | ||||||
return true; | ||||||
} | ||||||
|
||||||
return false; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Method called when we click the floating action button | ||||||
*/ | ||||||
showCreateMenu() { | ||||||
if (this.isInactive()) { | ||||||
// Prevent showing menu when click FAB icon quickly after opening other pages | ||||||
return; | ||||||
} | ||||||
this.setState({ | ||||||
isCreateMenuActive: true, | ||||||
}); | ||||||
|
@@ -76,6 +118,10 @@ class BaseSidebarScreen extends Component { | |||||
* Method called when avatar is clicked | ||||||
*/ | ||||||
navigateToSettings() { | ||||||
if (this.state.isCreateMenuActive) { | ||||||
// Prevent opening Settings page when click profile avatar quickly after clicking FAB icon | ||||||
return; | ||||||
} | ||||||
Navigation.navigate(ROUTES.SETTINGS); | ||||||
} | ||||||
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. Is there a possibility that we can move it inside the sidebarLinks component. 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. yes, similar to Search page |
||||||
|
||||||
|
@@ -85,6 +131,9 @@ class BaseSidebarScreen extends Component { | |||||
* Selecting an item on CreateMenu or closing it by clicking outside of the modal component | ||||||
*/ | ||||||
hideCreateMenu() { | ||||||
if (!this.state.isCreateMenuActive) { | ||||||
return; | ||||||
} | ||||||
Comment on lines
+136
to
+138
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. Do we need this? 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. yes to avoid unnecessary call when press shortcut key without opening popup menu |
||||||
this.props.onHideCreateMenu(); | ||||||
this.setState({ | ||||||
isCreateMenuActive: false, | ||||||
|
@@ -116,6 +165,7 @@ class BaseSidebarScreen extends Component { | |||||
onAvatarClick={this.navigateToSettings} | ||||||
isSmallScreenWidth={this.props.isSmallScreenWidth} | ||||||
isDrawerOpen={this.props.isDrawerOpen} | ||||||
isMenuOpen={this.state.isCreateMenuActive} | ||||||
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
|
||||||
reportIDFromRoute={this.props.reportIDFromRoute} | ||||||
/> | ||||||
<FloatingActionButton | ||||||
|
@@ -193,4 +243,4 @@ class BaseSidebarScreen extends Component { | |||||
BaseSidebarScreen.propTypes = propTypes; | ||||||
BaseSidebarScreen.defaultProps = defaultProps; | ||||||
|
||||||
export default withDrawerState(BaseSidebarScreen); | ||||||
export default withDrawerState(withNavigationFocus(BaseSidebarScreen)); | ||||||
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. Use |
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.
Missing jsDoc.
Only Param needs to be defined.