Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion app/packages/core/src/components/Grid/useEscape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@ const useEscape = () => {
}

const modal = await snapshot.getPromise(fos.modalSelector);
modal === null && reset(fos.selectedSamples);
const selectedSampleIds = await snapshot.getPromise(
fos.selectedSamples
);
// TODO: modal is always `null` here right after a modal closes, so this isn't the condition we want
if (modal === null && selectedSampleIds.size > 0) {
Comment on lines +24 to +25
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand. This seems to work. I assume only if propagation is stopped in looker?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think modal === null was put here to try to accomplish what this PR is actually accomplishing. Unfortunately, modal is always null here, so we do need this PR.

if (
confirm("Are you sure you want to clear your current selection?")
) {
reset(fos.selectedSamples);
}
}
},
[]
)
Expand Down
5 changes: 5 additions & 0 deletions app/packages/looker/src/elements/common/looker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ export class LookerElement<State extends BaseState> extends BaseElement<
SHORTCUTS,
error,
options: { shouldHandleKeyEvents },
config: { isModal },
} = state;
if (!error && e.key in SHORTCUTS) {
const matchedControl = SHORTCUTS[e.key] as Control;
const enabled =
shouldHandleKeyEvents || matchedControl.alwaysHandle;
if (enabled) {
matchedControl.action(update, dispatchEvent, e.key, e.shiftKey);

if (e.key === "Escape" && isModal) {
e.stopPropagation();
}
}
}

Expand Down
1 change: 1 addition & 0 deletions app/packages/looker/src/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export interface BaseConfig {
id: string;
name: string;
};
isModal?: boolean;
}

export interface FrameConfig extends BaseConfig {
Expand Down
1 change: 1 addition & 0 deletions app/packages/state/src/hooks/useCreateLooker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export default <T extends AbstractLooker<BaseState>>(
thumbnail,
view,
shouldHandleKeyEvents: isModal,
isModal,
};

let sampleMediaFilePath = urls[mediaField];
Expand Down
1 change: 1 addition & 0 deletions e2e-pw/src/oss/specs/selection.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ test.describe.serial("selection", () => {
// verify selection clears on escape
await grid.toggleSelectFirstSample();
await grid.assert.isSelectionCountEqualTo(1);
page.once("dialog", (dialog) => dialog.accept());
await page.press("body", "Escape");
await grid.assert.isSelectionCountEqualTo(0);

Expand Down
Loading