Skip to content

Commit f862e4a

Browse files
committed
add isModal explicitly to looker's state.config
use it to reliably stopPropagation of the Escape key event
1 parent 4e02f26 commit f862e4a

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

app/packages/looker/src/elements/common/looker.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export class LookerElement<State extends BaseState> extends BaseElement<
3030
SHORTCUTS,
3131
error,
3232
options: { shouldHandleKeyEvents },
33+
config: { isModal },
3334
} = state;
3435
if (!error && e.key in SHORTCUTS) {
3536
const matchedControl = SHORTCUTS[e.key] as Control;
@@ -38,9 +39,6 @@ export class LookerElement<State extends BaseState> extends BaseElement<
3839
if (enabled) {
3940
matchedControl.action(update, dispatchEvent, e.key, e.shiftKey);
4041

41-
// If this is a Modal, we don't want Escape to bubble up to the Grid
42-
// Hack: `lookerOptions` only sets showControl=true when a Modal
43-
const isModal = state.options.showControls === true;
4442
if (e.key === "Escape" && isModal) {
4543
e.stopPropagation();
4644
}

app/packages/looker/src/state.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ export interface BaseConfig {
222222
id: string;
223223
name: string;
224224
};
225+
isModal?: boolean;
225226
}
226227

227228
export interface FrameConfig extends BaseConfig {

app/packages/state/src/hooks/useCreateLooker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export default <T extends AbstractLooker<BaseState>>(
159159
thumbnail,
160160
view,
161161
shouldHandleKeyEvents: isModal,
162+
isModal,
162163
};
163164

164165
let sampleMediaFilePath = urls[mediaField];

0 commit comments

Comments
 (0)