Page MenuHomePhabricator

[native] Blocking navigation in edit mode in OverlayRouter
ClosedPublic

Authored by kuba on Jun 21 2023, 3:00 AM.
Tags
None
Referenced Files
F1700884: D8270.id28032.diff
Sat, May 4, 2:47 PM
F1700883: D8270.id.diff
Sat, May 4, 2:47 PM
F1700882: D8270.diff
Sat, May 4, 2:46 PM
F1700202: D8270.id28100.diff
Sat, May 4, 12:02 PM
Unknown Object (File)
Wed, Apr 24, 7:01 AM
Unknown Object (File)
Wed, Apr 24, 7:01 AM
Unknown Object (File)
Wed, Apr 24, 7:01 AM
Unknown Object (File)
Wed, Apr 24, 7:01 AM
Subscribers
None

Details

Summary

When we are in edit mode and the user made changes, we prevent him in this diff from opening modals i.g.:

  • opening images,
  • opening tooltips.
Test Plan
  • Enter edit mode,
  • Open the modal without making changes.
  • Enter edit mode and make changes to the message,
  • Open modal - should confirm with alert.
  • Check if the draft is restored.
  • Do the same in sidebar.

Video:

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

native/navigation/nav-selectors.js
328–331 ↗(On Diff #28032)

Usually the first route is the AppRouteName. Why is this different?

354–356 ↗(On Diff #28032)

Why is this necessary? When can chatRouteState.type not be 'stack'? Or is this something flow requires?

native/navigation/overlay-router.js
88 ↗(On Diff #28032)

I don't think a function that is called "get..." should have side effects. Getters typically don't have side effects

native/navigation/nav-selectors.js
328–331 ↗(On Diff #28032)

It is called from`OverlayRouter`, so it is nested.

354–356 ↗(On Diff #28032)

This function is based on drawerSwipeEnabledSelector function. It might be unnecessary. Not sure if I should remove it.

native/navigation/overlay-router.js
88 ↗(On Diff #28032)

I agree that it probably shouldn't have any side effects. But this is the only way I found how to display a confirmation alert when navigating, and then navigate when the user confirms that he wants to leave.

It is inspired by this doc.

native/navigation/nav-selectors.js
320–324 ↗(On Diff #28032)

It might be more readable using function syntax

kuba marked an inline comment as done.

Address review

native/navigation/overlay-router.js
88 ↗(On Diff #28032)

Rebase & fix calling dispatch from reducer

This revision is now accepted and ready to land.Jun 27 2023, 7:53 PM