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

fix: clear user select upon changing LHN tab #55516

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import useCurrentReportID from '@hooks/useCurrentReportID';
import useLocalize from '@hooks/useLocalize';
import useTheme from '@hooks/useTheme';
import useThemeStyles from '@hooks/useThemeStyles';
import clearSelectedText from '@libs/clearSelectedText/clearSelectedText';
import getPlatform from '@libs/getPlatform';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import Navigation from '@libs/Navigation/Navigation';
Expand Down Expand Up @@ -107,6 +108,7 @@ function BottomTabBar({selectedTab}: BottomTabBarProps) {
if (selectedTab === SCREENS.SEARCH.BOTTOM_TAB) {
return;
}
clearSelectedText();
interceptAnonymousUser(() => {
const rootState = navigationRef.getRootState() as State<RootStackParamList>;
const lastSearchRoute = rootState.routes.filter((route) => route.name === SCREENS.SEARCH.CENTRAL_PANE).at(-1);
Expand Down
5 changes: 5 additions & 0 deletions src/libs/clearSelectedText/clearSelectedText.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function clearSelectedText() {
return {};
}

export default clearSelectedText;
7 changes: 7 additions & 0 deletions src/libs/clearSelectedText/clearSelectedText.website.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/** Clears text that user selected by double-clicking -
* it's not tied to virtual DOM, so sometimes it has to be cleared manually */
function clearSelectedText() {
window.getSelection()?.removeAllRanges();
}

export default clearSelectedText;
2 changes: 2 additions & 0 deletions src/pages/home/sidebar/BottomTabAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import Text from '@components/Text';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
import clearSelectedText from '@libs/clearSelectedText/clearSelectedText';
import interceptAnonymousUser from '@libs/interceptAnonymousUser';
import Navigation from '@libs/Navigation/Navigation';
import CONST from '@src/CONST';
Expand Down Expand Up @@ -36,6 +37,7 @@ function BottomTabAvatar({isCreateMenuOpen = false, isSelected = false}: BottomT
return;
}

clearSelectedText();
interceptAnonymousUser(() => Navigation.navigate(ROUTES.SETTINGS));
}, [isCreateMenuOpen]);

Expand Down
Loading