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

see if CanvasOffsetWrapper fixes comment indicator scrolling #4782

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
16 changes: 6 additions & 10 deletions editor/src/components/canvas/controls/comment-indicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import * as EP from '../../../core/shared/element-path'
import { useRefAtom } from '../../editor/hook-utils'
import { emptyComments, jsExpressionValue } from '../../../core/shared/element-template'
import * as PP from '../../../core/shared/property-path'
import { CanvasOffsetWrapper } from './canvas-offset-wrapper'

export const CommentIndicators = React.memo(() => {
const projectId = useEditorState(
Expand Down Expand Up @@ -173,7 +174,7 @@ const CommentIndicatorsInner = React.memo(() => {
const temporaryIndicatorData = useCommentBeingComposed()

return (
<React.Fragment>
<CanvasOffsetWrapper>
{threads.map((thread) => (
<CommentIndicator key={thread.id} thread={thread} />
))}
Expand All @@ -189,7 +190,7 @@ const CommentIndicatorsInner = React.memo(() => {
isRead={false}
/>
) : null}
</React.Fragment>
</CanvasOffsetWrapper>
)
})
CommentIndicatorsInner.displayName = 'CommentIndicatorInner'
Expand Down Expand Up @@ -224,8 +225,8 @@ function getIndicatorStyle(
pointerEvents: dragging ? 'none' : undefined,
cursor: 'auto',
padding: 2,
position: 'fixed',
bottom: canvasHeight - position.y - positionAdjust,
position: 'absolute',
top: position.y, // warning this is no longer bottom positioned, it should be shifted downwards by the height
left: position.x,
background: isRead ? colorTheme.bg1.value : colorTheme.primary.value,
borderRadius: '24px 24px 24px 0px',
Expand Down Expand Up @@ -340,11 +341,6 @@ const CommentIndicator = React.memo(({ thread }: CommentIndicatorProps) => {
return !isActive && (hovered || dragging)
}, [hovered, isActive, dragging])

const position = React.useMemo(
() => canvasPointToWindowPoint(dragPosition ?? location, canvasScale, canvasOffset),
[location, canvasScale, canvasOffset, dragPosition],
)

const onMouseOut = React.useCallback(() => {
if (dragging) {
return
Expand Down Expand Up @@ -386,7 +382,7 @@ const CommentIndicator = React.memo(({ thread }: CommentIndicatorProps) => {
onMouseDown={onMouseDown}
onClick={onClick}
data-testid='comment-indicator'
css={getIndicatorStyle(position, {
css={getIndicatorStyle(location, {
isRead: isRead,
resolved: thread.metadata.resolved,
isActive: isActive,
Expand Down
Loading