Skip to content

Commit b7aa133

Browse files
remove withNavigationFocus from the report screen
1 parent 9004c39 commit b7aa133

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎src/pages/home/ReportScreen.js‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,10 @@ import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoun
3131
import withViewportOffsetTop, {viewportOffsetTopPropTypes} from '../../components/withViewportOffsetTop';
3232
import * as ReportActionsUtils from '../../libs/ReportActionsUtils';
3333
import personalDetailsPropType from '../personalDetailsPropType';
34-
import withNavigationFocus from '../../components/withNavigationFocus';
3534
import getIsReportFullyVisible from '../../libs/getIsReportFullyVisible';
3635
import * as EmojiPickerAction from '../../libs/actions/EmojiPickerAction';
3736
import MoneyRequestHeader from '../../components/MoneyRequestHeader';
3837
import MoneyReportHeader from '../../components/MoneyReportHeader';
39-
import withNavigation, {withNavigationPropTypes} from '../../components/withNavigation';
4038
import * as ComposerActions from '../../libs/actions/Composer';
4139
import ReportScreenContext from './ReportScreenContext';
4240
import TaskHeaderActionButton from '../../components/TaskHeaderActionButton';
@@ -88,7 +86,6 @@ const propTypes = {
8886

8987
...windowDimensionsPropTypes,
9088
...viewportOffsetTopPropTypes,
91-
...withNavigationPropTypes,
9289
};
9390

9491
const defaultProps = {
@@ -140,13 +137,18 @@ class ReportScreen extends React.Component {
140137

141138
this.flatListRef = React.createRef();
142139
this.reactionListRef = React.createRef();
140+
141+
// We need unique ID for drag and drop to work properly with stack navigator.
142+
this.dragAndDropId = CONST.REPORT.DROP_NATIVE_ID + ReportUtils.generateReportID();
143143
}
144144

145145
componentDidMount() {
146146
this.unsubscribeVisibilityListener = Visibility.onVisibilityChange(() => {
147+
const isTopMostReportId = Navigation.getTopmostReportId() === getReportID(this.props.route)
148+
147149
// If the report is not fully visible (AKA on small screen devices and LHR is open) or the report is optimistic (AKA not yet created)
148150
// we don't need to call openReport
149-
if (!getIsReportFullyVisible(this.props.isFocused) || this.props.report.isOptimisticReport) {
151+
if (!getIsReportFullyVisible(isTopMostReportId) || this.props.report.isOptimisticReport) {
150152
return;
151153
}
152154

@@ -210,11 +212,6 @@ class ReportScreen extends React.Component {
210212
Report.addComment(getReportID(this.props.route), text);
211213
}
212214

213-
getNavigationKey() {
214-
const navigation = this.props.navigation.getState();
215-
return lodashGet(navigation.routes, [navigation.index, 'key']);
216-
}
217-
218215
/**
219216
* When false the ReportActionsView will completely unmount and we will show a loader until it returns true.
220217
*
@@ -273,6 +270,8 @@ class ReportScreen extends React.Component {
273270

274271
const policy = this.props.policies[`${ONYXKEYS.COLLECTION.POLICY}${this.props.report.policyID}`];
275272

273+
const isTopMostReportId = Navigation.getTopmostReportId() === getReportID(this.props.route)
274+
276275
let headerView = (
277276
<HeaderView
278277
reportID={reportID}
@@ -315,7 +314,7 @@ class ReportScreen extends React.Component {
315314
>
316315
<ScreenWrapper
317316
style={screenWrapperStyle}
318-
shouldEnableKeyboardAvoidingView={this.props.isFocused}
317+
shouldEnableKeyboardAvoidingView={isTopMostReportId}
319318
>
320319
<FullPageNotFoundView
321320
shouldShow={(!this.props.report.reportID && !this.props.report.isLoadingReportActions && !isLoading && !this.state.isReportRemoved) || shouldHideReport}
@@ -351,7 +350,7 @@ class ReportScreen extends React.Component {
351350
/>
352351
)}
353352
<View
354-
nativeID={CONST.REPORT.DROP_NATIVE_ID + this.getNavigationKey()}
353+
nativeID={this.dragAndDropId}
355354
style={[styles.flex1, styles.justifyContentEnd, styles.overflowHidden]}
356355
onLayout={(event) => {
357356
// Rounding this value for comparison because they can look like this: 411.9999694824219
@@ -396,6 +395,7 @@ class ReportScreen extends React.Component {
396395
isComposerFullSize={this.props.isComposerFullSize}
397396
onSubmitComment={this.onSubmitComment}
398397
policies={this.props.policies}
398+
dragAndDropId={this.dragAndDropId}
399399
/>
400400
</>
401401
)}
@@ -404,6 +404,7 @@ class ReportScreen extends React.Component {
404404
<ReportFooter
405405
shouldDisableCompose
406406
isOffline={this.props.network.isOffline}
407+
dragAndDropId={this.dragAndDropId}
407408
/>
408409
)}
409410

@@ -423,8 +424,6 @@ export default compose(
423424
withViewportOffsetTop,
424425
withLocalize,
425426
withWindowDimensions,
426-
withNavigationFocus,
427-
withNavigation,
428427
withNetwork(),
429428
withOnyx({
430429
isSidebarLoaded: {

‎src/pages/home/report/ReportActionCompose.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ class ReportActionCompose extends React.Component {
11131113
</AttachmentPicker>
11141114
<View style={[styles.textInputComposeSpacing, styles.textInputComposeBorder]}>
11151115
<DragAndDrop
1116-
dropZoneId={CONST.REPORT.DROP_NATIVE_ID + this.getNavigationKey()}
1116+
dropZoneId={this.props.dragAndDropId}
11171117
activeDropZoneId={CONST.REPORT.ACTIVE_DROP_NATIVE_ID + this.props.reportID}
11181118
onDragEnter={() => {
11191119
this.setState({isDraggingOver: true});

‎src/pages/home/report/ReportFooter.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ function ReportFooter(props) {
9292
pendingAction={props.pendingAction}
9393
isComposerFullSize={props.isComposerFullSize}
9494
disabled={props.shouldDisableCompose}
95+
dragAndDropId={props.dragAndDropId}
9596
/>
9697
</SwipeableView>
9798
</View>

0 commit comments

Comments
 (0)