@@ -31,12 +31,10 @@ import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoun
3131import withViewportOffsetTop , { viewportOffsetTopPropTypes } from '../../components/withViewportOffsetTop' ;
3232import * as ReportActionsUtils from '../../libs/ReportActionsUtils' ;
3333import personalDetailsPropType from '../personalDetailsPropType' ;
34- import withNavigationFocus from '../../components/withNavigationFocus' ;
3534import getIsReportFullyVisible from '../../libs/getIsReportFullyVisible' ;
3635import * as EmojiPickerAction from '../../libs/actions/EmojiPickerAction' ;
3736import MoneyRequestHeader from '../../components/MoneyRequestHeader' ;
3837import MoneyReportHeader from '../../components/MoneyReportHeader' ;
39- import withNavigation , { withNavigationPropTypes } from '../../components/withNavigation' ;
4038import * as ComposerActions from '../../libs/actions/Composer' ;
4139import ReportScreenContext from './ReportScreenContext' ;
4240import TaskHeaderActionButton from '../../components/TaskHeaderActionButton' ;
@@ -88,7 +86,6 @@ const propTypes = {
8886
8987 ...windowDimensionsPropTypes ,
9088 ...viewportOffsetTopPropTypes ,
91- ...withNavigationPropTypes ,
9289} ;
9390
9491const 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 : {
0 commit comments