Skip to content

Commit 381fed6

Browse files
committed
fix(desktop): improve crop options menu click and positioning
1 parent d78b33f commit 381fed6

4 files changed

Lines changed: 7 additions & 10 deletions

File tree

apps/desktop/src/routes/capture-area.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ export default function CaptureArea() {
157157

158158
async function showCropOptionsMenu(e: UIEvent, positionAtCursor = false) {
159159
e.preventDefault();
160+
e.stopPropagation();
160161
const items = createCropOptionsMenuItems({
161162
aspect: aspect(),
162163
snapToRatioEnabled: state.snapToRatio,
@@ -166,11 +167,10 @@ export default function CaptureArea() {
166167
const menu = await Menu.new({ items });
167168
let pos: LogicalPosition | undefined;
168169
if (!positionAtCursor) {
169-
const rect = (e.target as HTMLDivElement).getBoundingClientRect();
170+
const rect = (e.currentTarget as HTMLDivElement).getBoundingClientRect();
170171
pos = new LogicalPosition(rect.x, rect.y + 50);
171172
}
172173
await menu.popup(pos);
173-
await menu.close();
174174
}
175175

176176
return (
@@ -222,7 +222,6 @@ export default function CaptureArea() {
222222
title="Aspect Ratio"
223223
class="group flex items-center justify-center size-10 text-gray-11 hover:bg-gray-5 active:bg-gray-6 rounded-full transition-colors duration-200 cursor-default"
224224
type="button"
225-
onMouseDown={showCropOptionsMenu}
226225
onClick={showCropOptionsMenu}
227226
>
228227
<div class="relative size-5 pointer-events-none">

apps/desktop/src/routes/editor/Editor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -989,6 +989,7 @@ function Dialogs() {
989989
positionAtCursor = false,
990990
) {
991991
e.preventDefault();
992+
e.stopPropagation();
992993
const items = createCropOptionsMenuItems({
993994
aspect: aspect(),
994995
snapToRatioEnabled: snapToRatio(),
@@ -999,12 +1000,11 @@ function Dialogs() {
9991000
let pos: LogicalPosition | undefined;
10001001
if (!positionAtCursor) {
10011002
const rect = (
1002-
e.target as HTMLDivElement
1003+
e.currentTarget as HTMLDivElement
10031004
).getBoundingClientRect();
10041005
pos = new LogicalPosition(rect.x, rect.y + 40);
10051006
}
10061007
await menu.popup(pos);
1007-
await menu.close();
10081008
}
10091009

10101010
function BoundInput(props: {
@@ -1065,7 +1065,6 @@ function Dialogs() {
10651065
variant="white"
10661066
size="xs"
10671067
class="flex items-center justify-center text-center rounded-full h-[2rem] w-[2rem] border focus:border-blue-9"
1068-
onMouseDown={showCropOptionsMenu}
10691068
onClick={showCropOptionsMenu}
10701069
>
10711070
<div class="relative pointer-events-none size-4">

apps/desktop/src/routes/screenshot-editor/Editor.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ function Dialogs() {
256256
positionAtCursor = false,
257257
) {
258258
e.preventDefault();
259+
e.stopPropagation();
259260
const items = createCropOptionsMenuItems({
260261
aspect: aspect(),
261262
snapToRatioEnabled: snapToRatio(),
@@ -266,12 +267,11 @@ function Dialogs() {
266267
let pos: LogicalPosition | undefined;
267268
if (!positionAtCursor) {
268269
const rect = (
269-
e.target as HTMLDivElement
270+
e.currentTarget as HTMLDivElement
270271
).getBoundingClientRect();
271272
pos = new LogicalPosition(rect.x, rect.y + 40);
272273
}
273274
await menu.popup(pos);
274-
await menu.close();
275275
}
276276

277277
function BoundInput(props: {
@@ -332,7 +332,6 @@ function Dialogs() {
332332
variant="white"
333333
size="xs"
334334
class="flex items-center justify-center text-center rounded-full h-[2rem] w-[2rem] border focus:border-blue-9"
335-
onMouseDown={showCropOptionsMenu}
336335
onClick={showCropOptionsMenu}
337336
>
338337
<div class="relative pointer-events-none size-4">

apps/desktop/src/routes/target-select-overlay.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ function Inner() {
897897

898898
async function showCropOptionsMenu(e: UIEvent) {
899899
e.preventDefault();
900+
e.stopPropagation();
900901
const items = [
901902
{
902903
text: "Reset selection",
@@ -919,7 +920,6 @@ function Inner() {
919920
];
920921
const menu = await Menu.new({ items });
921922
await menu.popup();
922-
await menu.close();
923923
}
924924

925925
// Spacing rules:

0 commit comments

Comments
 (0)