Skip to content

Commit 083e06d

Browse files
authored
Merge pull request #200 from sillsdev/TT-7044
TT-7044 don't ignore zoom inside more menu, fix zoom width reset when…
2 parents d61aafd + 745491c commit 083e06d

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

src/renderer/src/components/WSAudioPlayer.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,11 +1328,16 @@ function WSAudioPlayer(props: IProps) {
13281328
flexDirection: 'column',
13291329
whiteSpace: 'nowrap',
13301330
width: '100%',
1331+
minWidth: 0,
1332+
overflowX: 'auto',
13311333
}}
13321334
style={style}
13331335
>
13341336
<>
1335-
<Grid container sx={toolbarProp}>
1337+
<Grid
1338+
container
1339+
sx={{ ...toolbarProp, minWidth: 0, flexWrap: 'nowrap' }}
1340+
>
13361341
<Grid sx={{ ml: 1 }}>
13371342
<LightTooltip id="wsAudioPlayTip" title={playTooltipTitle}>
13381343
<span>
@@ -1485,8 +1490,16 @@ function WSAudioPlayer(props: IProps) {
14851490
>
14861491
{allowZoom && (
14871492
<MenuItem
1488-
onClick={handleMoreMenuClose}
1489-
sx={{ pointerEvents: 'none' }}
1493+
onClick={(e) => {//don't close menu if zoom in or out button is clicked
1494+
const target = e.target as HTMLElement;
1495+
if (
1496+
target.closest?.(
1497+
'[id="wsZoomIn"], [id="wsZoomOut"]'
1498+
)
1499+
)
1500+
return;
1501+
handleMoreMenuClose();
1502+
}}
14901503
>
14911504
<WSAudioPlayerZoom
14921505
ready={ready && !recording && !waitingForAI}

src/renderer/src/components/WSAudioPlayerZoom.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ function WSAudioPlayerZoom(props: IProps) {
3131

3232
const t: IWsAudioPlayerZoomStrings = useSelector(audioPlayerZoomSelector);
3333
const readyRef = useRef(ready);
34+
const prevFillPxRef = useRef<number | undefined>(undefined);
3435

3536
const ZOOMIN_KEY = 'CTRL+1';
3637
const ZOOMOUT_KEY = 'CTRL+3';
@@ -51,8 +52,16 @@ function WSAudioPlayerZoom(props: IProps) {
5152
if (tellParent) onZoom(value);
5253
};
5354
useEffect(() => {
54-
setZoom(fillPx);
5555
setZoomMin(fillPx);
56+
// Only sync zoom to fillPx when fillPx actually changes (e.g. resize), not on mount.
57+
// On mount, curPx effect sets zoom; avoid overwriting with fillPx so menu reopen keeps zoom.
58+
if (
59+
prevFillPxRef.current !== undefined &&
60+
prevFillPxRef.current !== fillPx
61+
) {
62+
setZoom(fillPx);
63+
}
64+
prevFillPxRef.current = fillPx;
5665
// eslint-disable-next-line react-hooks/exhaustive-deps
5766
}, [fillPx]);
5867

@@ -79,12 +88,10 @@ function WSAudioPlayerZoom(props: IProps) {
7988
];
8089
keys.forEach((k) => subscribe(k.key, k.cb));
8190
return () => {
82-
// eslint-disable-next-line react-hooks/exhaustive-deps
8391
keys.forEach((k) => unsubscribe(k.key));
8492
};
8593
// eslint-disable-next-line react-hooks/exhaustive-deps
8694
}, []);
87-
8895
return (
8996
<GrowingDiv>
9097
<ToolbarGrid container>

0 commit comments

Comments
 (0)