Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(acceptance): keep the video comment button beside the player (#21680)

Bryan3a2f1d1852fa
diff --git a/src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.test.tsx b/src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.test.tsx
index accda46faf3..394e89c784d 100644
--- a/src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.test.tsx
+++ b/src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.test.tsx
@@ -42,8 +42,30 @@ describe('VideoEvidencePlayer sizing', () => {
video.dispatchEvent(new Event('loadedmetadata'));
});
- expect(video.closest('[tabindex="0"]')).toHaveStyle({
+ expect(video.closest('[data-acceptance-video-host]')).toHaveStyle({
maxWidth: `min(100%, ${maxWidth}px)`,
});
});
+
+ // The comment action floats at the host's edge: a host wider than the
+ // player left it far from a narrow recording.
+ it('keeps the comment action beside the player instead of the column edge', () => {
+ const { container } = render(
+ <VideoEvidencePlayer src={'https://s3/clip.mp4'} onComment={vi.fn()} />,
+ );
+ const video = container.querySelector('video')!;
+ Object.defineProperties(video, {
+ videoHeight: { configurable: true, value: 1920 },
+ videoWidth: { configurable: true, value: 1080 },
+ });
+
+ act(() => {
+ video.dispatchEvent(new Event('loadedmetadata'));
+ });
+
+ const host = video.closest('[data-acceptance-video-host]')!;
+ expect(host).toHaveStyle({ maxWidth: 'min(100%, 480px)' });
+ expect(host.firstElementChild).toHaveStyle({ width: '100%' });
+ expect(host.querySelector('[title]')).not.toBeNull();
+ });
});
diff --git a/src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.tsx b/src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.tsx
index c092cacb578..24b8f9fa9e5 100644
--- a/src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.tsx
+++ b/src/features/Acceptance/Viewer/Evidence/Video/VideoEvidencePlayer.tsx
@@ -174,7 +174,19 @@ export const VideoEvidencePlayer = memo<VideoEvidencePlayerProps>(
return (
<Flexbox gap={8} ref={root} width={'100%'}>
- <div {...{ [FLOATING_ACTION_HOST]: '' }} style={{ position: 'relative', width: '100%' }}>
+ {/* The host takes the player's width, so the comment action floats right
+ beside a narrow recording instead of at the far edge of the column. */}
+ <div
+ {...{ [FLOATING_ACTION_HOST]: '' }}
+ data-acceptance-video-host
+ style={{
+ maxWidth: frameMaxHeight
+ ? `max(${MIN_PLAYER_WIDTH}px, calc(${frameMaxHeight} * ${aspect}))`
+ : `min(100%, ${Math.max(MIN_PLAYER_WIDTH, frameWidth)}px)`,
+ position: 'relative',
+ width: '100%',
+ }}
+ >
<Video.Root
className={cx(styles.player, styles.compactControls)}
defaultPlaybackRate={defaultRate}
@@ -189,10 +201,7 @@ export const VideoEvidencePlayer = memo<VideoEvidencePlayerProps>(
'--acceptance-video-frame-width': frameMaxHeight
? `calc(${frameMaxHeight} * ${aspect})`
: `${frameWidth}px`,
- 'width': frameMaxHeight ? '100%' : undefined,
- 'maxWidth': frameMaxHeight
- ? `max(${MIN_PLAYER_WIDTH}px, calc(${frameMaxHeight} * ${aspect}))`
- : `min(100%, ${Math.max(MIN_PLAYER_WIDTH, frameWidth)}px)`,
+ 'width': '100%',
} as CSSProperties
}
onRateChange={storeRate}