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
F3404816: D8270.diff
Tue, Dec 3, 1:17 PM
Unknown Object (File)
Sat, Nov 23, 1:45 PM
Unknown Object (File)
Sat, Nov 23, 1:08 PM
Unknown Object (File)
Sat, Nov 23, 1:08 PM
Unknown Object (File)
Sat, Nov 23, 1:08 PM
Unknown Object (File)
Sat, Nov 23, 7:05 AM
Unknown Object (File)
Fri, Nov 8, 5:31 AM
Unknown Object (File)
Oct 30 2024, 7:22 PM
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
No Lint Coverage
Unit
No Test Coverage

Event Timeline

native/navigation/nav-selectors.js
328–331

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

354–356

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

native/navigation/overlay-router.js
88

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

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

354–356

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

native/navigation/overlay-router.js
88

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

It might be more readable using function syntax

kuba marked an inline comment as done.

Address review

native/navigation/overlay-router.js
88

Rebase & fix calling dispatch from reducer

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