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 composer is still focused when context menu is shown #51309

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
2 changes: 2 additions & 0 deletions src/components/FocusTrap/FocusTrapForModal/index.web.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FocusTrap from 'focus-trap-react';
import React from 'react';
import sharedTrapStack from '@components/FocusTrap/sharedTrapStack';
import blurActiveElement from '@libs/Accessibility/blurActiveElement';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import type FocusTrapForModalProps from './FocusTrapForModalProps';

Expand All @@ -9,6 +10,7 @@ function FocusTrapForModal({children, active, initialFocus = false}: FocusTrapFo
<FocusTrap
active={active}
focusTrapOptions={{
onActivate: blurActiveElement,
trapStack: sharedTrapStack,
clickOutsideDeactivates: true,
initialFocus,
Expand Down
9 changes: 0 additions & 9 deletions src/libs/ReportActionComposeFocusManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ function isEditFocused(): boolean {
return !!editComposerRef.current?.isFocused();
}

/**
* Utility function to blur both main composer and edit composer.
*/
function blurAll(): void {
composerRef.current?.blur();
editComposerRef.current?.blur();
}

export default {
composerRef,
onComposerFocus,
Expand All @@ -98,5 +90,4 @@ export default {
isFocused,
editComposerRef,
isEditFocused,
blurAll,
};
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ function BaseReportActionContextMenu({
}: BaseReportActionContextMenuProps) {
const StyleUtils = useStyleUtils();
const {translate} = useLocalize();
const {shouldUseNarrowLayout} = useResponsiveLayout();
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {shouldUseNarrowLayout, isSmallScreenWidth} = useResponsiveLayout();
const menuItemRefs = useRef<MenuItemRefs>({});
const [shouldKeepOpen, setShouldKeepOpen] = useState(false);
const wrapperStyle = StyleUtils.getReportActionContextMenuStyles(isMini, shouldUseNarrowLayout);
Expand Down Expand Up @@ -301,7 +302,7 @@ function BaseReportActionContextMenu({

return (
(isVisible || shouldKeepOpen) && (
<FocusTrapForModal active={!isMini}>
<FocusTrapForModal active={!isMini && !isSmallScreenWidth}>
<View
ref={contentRef}
style={wrapperStyle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ function PopoverReportActionContextMenu(_props: unknown, ref: ForwardedRef<Repor
shoudSwitchPositionIfOverflow={shoudSwitchPositionIfOverflow}
>
<BaseReportActionContextMenu
isVisible
isVisible={isPopoverVisible}
type={typeRef.current}
reportID={reportIDRef.current}
reportActionID={reportActionIDRef.current}
Expand Down
2 changes: 0 additions & 2 deletions src/pages/home/report/ReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import Navigation from '@libs/Navigation/Navigation';
import Permissions from '@libs/Permissions';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import * as PolicyUtils from '@libs/PolicyUtils';
import ReportActionComposeFocusManager from '@libs/ReportActionComposeFocusManager';
import * as ReportActionsUtils from '@libs/ReportActionsUtils';
import * as ReportUtils from '@libs/ReportUtils';
import SelectionScraper from '@libs/SelectionScraper';
Expand Down Expand Up @@ -339,7 +338,6 @@ function ReportActionItem({
return;
}

ReportActionComposeFocusManager.blurAll();
setIsContextMenuActive(true);
const selection = SelectionScraper.getCurrentSelection();
ReportActionContextMenu.showContextMenu(
Expand Down
Loading