diff --git a/services/web/frontend/js/features/editor-floating-menu/editor-floating-menu.tsx b/services/web/frontend/js/features/editor-floating-menu/editor-floating-menu.tsx
index 5d6f4f48ef..0033954a06 100644
--- a/services/web/frontend/js/features/editor-floating-menu/editor-floating-menu.tsx
+++ b/services/web/frontend/js/features/editor-floating-menu/editor-floating-menu.tsx
@@ -41,6 +41,7 @@ const editorFloatingMenuActions = importOverleafModules(
const EditorFloatingMenu: FC = () => {
const state = useCodeMirrorStateContext()
const view = useCodeMirrorViewContext()
+ const { focusMode } = useLayoutContext()
const [show, setShow] = useState(true)
const tooltipState = state.field(reviewTooltipField, false)
const previousTooltipState = usePreviousValue(tooltipState)
@@ -72,7 +73,7 @@ const EditorFloatingMenu: FC = () => {
}
}, [show, tooltipState, view])
- if (!show || !tooltipState) {
+ if (focusMode || !show || !tooltipState) {
return null
}
diff --git a/services/web/frontend/js/features/source-editor/hooks/use-context-menu-items.tsx b/services/web/frontend/js/features/source-editor/hooks/use-context-menu-items.tsx
index 12d6652aa7..09e5ee78de 100644
--- a/services/web/frontend/js/features/source-editor/hooks/use-context-menu-items.tsx
+++ b/services/web/frontend/js/features/source-editor/hooks/use-context-menu-items.tsx
@@ -50,6 +50,7 @@ export const useContextMenuItems = () => {
changeLayout,
pdfLayout,
view: ideView,
+ focusMode,
} = useLayoutContext()
const visualPreviewEnabled = useFeatureFlag('visual-preview')
const { t } = useTranslation()
@@ -306,7 +307,7 @@ export const useContextMenuItems = () => {
label: t('comment'),
handler: handleComment,
disabled: isCursorOnEmptyLine(state),
- show: permissions.comment,
+ show: permissions.comment && !focusMode,
shortcut: getShortcut('insert-comment'),
},
{
diff --git a/services/web/test/frontend/features/editor-floating-menu/editor-floating-menu.spec.tsx b/services/web/test/frontend/features/editor-floating-menu/editor-floating-menu.spec.tsx
index 582b01c0a6..2b15146d73 100644
--- a/services/web/test/frontend/features/editor-floating-menu/editor-floating-menu.spec.tsx
+++ b/services/web/test/frontend/features/editor-floating-menu/editor-floating-menu.spec.tsx
@@ -28,11 +28,13 @@ describe('', function () {
trackChangesVisible = true,
floatingMenu = true,
withSettingsToggle = false,
+ focusMode = false,
}: {
migrationEnabled: boolean
trackChangesVisible?: boolean
floatingMenu?: boolean
withSettingsToggle?: boolean
+ focusMode?: boolean
}) {
window.metaAttributesCache.set('ol-preventCompileOnLoad', true)
window.metaAttributesCache.set('ol-splitTestVariants', {
@@ -49,6 +51,7 @@ describe('', function () {
scope={scope}
features={{ trackChangesVisible }}
userSettings={{ floatingMenu }}
+ layoutContext={{ focusMode }}
>
{withSettingsToggle && }
@@ -150,6 +153,14 @@ describe('', function () {
})
})
+ describe('when in focus mode', function () {
+ it('does not show the floating menu', function () {
+ mountEditor({ migrationEnabled: true, focusMode: true })
+
+ cy.get('.editor-floating-menu').should('not.exist')
+ })
+ })
+
describe('when the migration split test is disabled (control)', function () {
it('keeps the legacy review tooltip and does not render the unified menu', function () {
mountEditor({ migrationEnabled: false })
diff --git a/services/web/test/frontend/features/source-editor/components/codemirror-editor-context-menu.spec.tsx b/services/web/test/frontend/features/source-editor/components/codemirror-editor-context-menu.spec.tsx
index 9edb2d39ab..81cf77301c 100644
--- a/services/web/test/frontend/features/source-editor/components/codemirror-editor-context-menu.spec.tsx
+++ b/services/web/test/frontend/features/source-editor/components/codemirror-editor-context-menu.spec.tsx
@@ -365,6 +365,35 @@ describe('editor context menu', { scrollBehavior: false }, function () {
})
})
+ describe('when in focus mode', function () {
+ it('should hide the Add Comment item but keeps the other actions', function () {
+ const scope = mockScope()
+
+ cy.mount(
+
+
+
+
+
+ )
+
+ cy.get('.cm-line').eq(10).rightclick()
+
+ cy.findByRole('menu').within(() => {
+ cy.findByRole('menuitem', { name: /cut/i }).should('be.enabled')
+ cy.findByRole('menuitem', { name: /copy/i }).should('be.enabled')
+ cy.findByRole('menuitem', { name: /suggest edits/i }).should(
+ 'be.enabled'
+ )
+ cy.findByRole('menuitem', { name: /comment/i }).should('not.exist')
+ })
+ })
+ })
+
describe('when text is selected', function () {
it('should enable Cut, Copy, Paste, Delete, Suggest edits, and Comment', function () {
const scope = mockScope()