Skip to content
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

DOM: Blur activeElement before navigation #15249

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Keyboard} from 'react-native';
import {DrawerActions, getPathFromState, StackActions} from '@react-navigation/native';
import Onyx from 'react-native-onyx';
import Log from '../Log';
import DomUtils from '../DomUtils';
import linkTo from './linkTo';
import ROUTES from '../../ROUTES';
import DeprecatedCustomActions from './DeprecatedCustomActions';
Expand Down Expand Up @@ -158,6 +159,11 @@ function navigate(route = ROUTES.HOME) {
return;
}

// A pressed navigation button will remain focused, keeping its tooltip visible, even if it's supposed to be out of view.
// To prevent that we blur the button manually (especially for Safari, where the mouse leave event is missing).
// More info: https://github.com/Expensify/App/issues/13146
DomUtils.blurActiveElement();

if (route === ROUTES.HOME) {
if (isLoggedIn && pendingRoute === null) {
openDrawer();
Expand Down
7 changes: 0 additions & 7 deletions src/libs/Navigation/NavigationRoot.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import AppNavigator from './AppNavigator';
import FullScreenLoadingIndicator from '../../components/FullscreenLoadingIndicator';
import themeColors from '../../styles/themes/default';
import styles from '../../styles/styles';
import DomUtils from '../DomUtils';
import Log from '../Log';

// https://reactnavigation.org/docs/themes
Expand Down Expand Up @@ -46,12 +45,6 @@ function parseAndLogRoute(state) {
Log.info('Navigating to route', false, {path: currentPath});
}

// Clicking a button that does navigation will stay active even if it's out of view
// and it's tooltip will stay visible.
// We blur the element manually to fix that (especially for Safari).
// More info: https://github.com/Expensify/App/issues/13146
DomUtils.blurActiveElement();

Navigation.setIsNavigationReady();
}

Expand Down