From 9f80dd48e8852eeb9d4117049f3624a02f0840c7 Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Tue, 21 Nov 2023 14:49:03 +0000 Subject: [PATCH] Merge pull request #15814 from overleaf/td-review-panel-indicator-hover Fix review panel comment hover bug GitOrigin-RevId: ddd6f8f073a2af189c990c8942a388cae412f8c6 --- .../review-panel/entries/entry-container.tsx | 11 +++++-- .../review-panel/hooks/use-indicator-hover.ts | 20 +++++-------- .../stylesheets/app/editor/review-panel.less | 30 +++++++++++++++---- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/services/web/frontend/js/features/source-editor/components/review-panel/entries/entry-container.tsx b/services/web/frontend/js/features/source-editor/components/review-panel/entries/entry-container.tsx index fc2d2302e3..bf07bac22d 100644 --- a/services/web/frontend/js/features/source-editor/components/review-panel/entries/entry-container.tsx +++ b/services/web/frontend/js/features/source-editor/components/review-panel/entries/entry-container.tsx @@ -1,6 +1,7 @@ -import classnames from 'classnames' +import classNames from 'classnames' import { createPortal } from 'react-dom' import { Coordinates } from '../hooks/use-indicator-hover' +import useScopeValue from '@/shared/hooks/use-scope-value' function EntryContainer({ id, @@ -10,9 +11,11 @@ function EntryContainer({ }: React.ComponentProps<'div'> & { hoverCoords?: Coordinates | null }) { + const [layoutToLeft] = useScopeValue('reviewPanel.layoutToLeft') + const container = (
@@ -22,7 +25,9 @@ function EntryContainer({ // Render in a floating positioned container return createPortal(
{container} diff --git a/services/web/frontend/js/features/source-editor/components/review-panel/hooks/use-indicator-hover.ts b/services/web/frontend/js/features/source-editor/components/review-panel/hooks/use-indicator-hover.ts index 1a6e25da62..2e40038d41 100644 --- a/services/web/frontend/js/features/source-editor/components/review-panel/hooks/use-indicator-hover.ts +++ b/services/web/frontend/js/features/source-editor/components/review-panel/hooks/use-indicator-hover.ts @@ -2,7 +2,6 @@ import { useCallback, useEffect, useRef, useState } from 'react' import { flushSync } from 'react-dom' import { useReviewPanelUpdaterFnsContext } from '../../../context/review-panel/review-panel-context' import { useLayoutContext } from '../../../../../shared/context/layout-context' -import useScopeValue from '../../../../../shared/hooks/use-scope-value' import EntryIndicator from '../entries/entry-indicator' export type Coordinates = { @@ -12,7 +11,6 @@ export type Coordinates = { function useIndicatorHover() { const [hoverCoords, setHoverCoords] = useState(null) - const [layoutToLeft] = useScopeValue('reviewPanel.layoutToLeft') const { toggleReviewPanel } = useReviewPanelUpdaterFnsContext() const { reviewPanelOpen } = useLayoutContext() const { setLayoutSuspended, handleLayoutChange } = @@ -22,7 +20,7 @@ function useIndicatorHover() { ) const endHover = useCallback(() => { - if (!reviewPanelOpen && !layoutToLeft) { + if (!reviewPanelOpen) { // Use flushSync to ensure that React renders immediately. This is // necessary to ensure that the subsequent layout update acts on the // updated DOM. @@ -32,17 +30,15 @@ function useIndicatorHover() { }) handleLayoutChange({ force: true }) } - }, [handleLayoutChange, layoutToLeft, reviewPanelOpen, setLayoutSuspended]) + }, [handleLayoutChange, reviewPanelOpen, setLayoutSuspended]) const handleIndicatorMouseEnter = () => { - if (!layoutToLeft) { - const rect = indicatorRef.current?.getBoundingClientRect() - setHoverCoords({ - x: rect?.left || 0, - y: rect?.top || 0, - }) - setLayoutSuspended(true) - } + const rect = indicatorRef.current?.getBoundingClientRect() + setHoverCoords({ + x: rect?.left || 0, + y: rect?.top || 0, + }) + setLayoutSuspended(true) } const handleIndicatorClick = () => { diff --git a/services/web/frontend/stylesheets/app/editor/review-panel.less b/services/web/frontend/stylesheets/app/editor/review-panel.less index deb6a7a6ce..c86bde1e76 100644 --- a/services/web/frontend/stylesheets/app/editor/review-panel.less +++ b/services/web/frontend/stylesheets/app/editor/review-panel.less @@ -327,16 +327,14 @@ top: 0; } - .rp-state-current-file-mini.rp-layout-left & { - left: auto; - right: @review-off-width + @rp-entry-arrow-width; + .rp-state-current-file-mini.rp-layout-left &, + .rp-floating-entry-layout-left & { border-left-width: 0; border-right-width: @rp-entry-ribbon-width; border-right-style: solid; &::before { left: -(@review-off-width + @rp-entry-arrow-width); - right: -(2 * @rp-entry-arrow-width + 2); } &::after { @@ -351,6 +349,23 @@ } } + .rp-state-current-file-mini.rp-layout-left & { + left: auto; + right: @review-off-width + @rp-entry-arrow-width; + + &::before { + right: -(2 * @rp-entry-arrow-width + 2); + } + } + + .rp-floating-entry-layout-left & { + left: -(@review-panel-width + @rp-entry-arrow-width + 2); + + &::before { + right: -(2 * @rp-entry-arrow-width); + } + } + .rp-state-current-file-expanded & { visibility: hidden; left: 5px; @@ -518,7 +533,8 @@ border-right-width: 0; } - .rp-state-current-file-mini.rp-layout-left & { + .rp-state-current-file-mini.rp-layout-left &, + .rp-floating-entry-layout-left & { &:first-child { border-bottom-left-radius: 3px; } @@ -1276,6 +1292,10 @@ button when (@is-overleaf-light = true) { .rp-entry-list-react { position: relative; overflow: hidden; + + .rp-size-mini & { + overflow: visible; + } } .rp-state-current-file & {