fix(engine): close Settings, Help, Leaderboard, and theme store on Esc
Test / test (pull_request) Successful in 10m16s
Test / test (pull_request) Successful in 10m16s
Phase C dismissal audit: Esc / scrim-tap / Done must behave the same on every modal. Stragglers found and fixed — none of these had any Esc path (pause's toggle guard swallowed the key while they were open): - Settings: Esc clears SettingsScreen, gated on being the topmost modal so a stacked sync-setup / theme-store dialog owns Esc - Help: Esc closes alongside F1/Done (the code comment already claimed an Esc path existed — now it does) - Leaderboard: Esc closes when topmost; the display-name dialog stacked above it now Esc-cancels like sync-setup's dialog - Theme store: Esc closes (always topmost when open) Scrim-tap opt-ins are unchanged — ui_modal documents which modals deliberately stay non-dismissible on outside clicks. Tests: escape_closes_help_screen, escape_closes_settings_screen_flag. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -118,6 +118,9 @@ impl Plugin for ThemeStorePlugin {
|
||||
.init_resource::<CatalogTask>()
|
||||
.init_resource::<InstallTask>()
|
||||
.init_resource::<StoreBaseUrl>()
|
||||
// Esc-close reads keyboard input; register defensively so
|
||||
// the plugin works under MinimalPlugins in tests.
|
||||
.init_resource::<ButtonInput<KeyCode>>()
|
||||
.add_message::<ThemeStoreOpenRequestEvent>()
|
||||
.add_message::<InfoToastEvent>()
|
||||
.add_message::<WarningToastEvent>()
|
||||
@@ -344,19 +347,23 @@ fn poll_install_task(
|
||||
);
|
||||
}
|
||||
|
||||
/// Despawns the store modal when Close is pressed.
|
||||
/// Despawns the store modal when Close is pressed or on Esc (Phase C
|
||||
/// dismissal audit). The store only ever stacks over Settings and
|
||||
/// nothing stacks over the store, so it owns Esc whenever it is open
|
||||
/// (Settings' own Esc handler is gated on being topmost).
|
||||
fn handle_close_button(
|
||||
interactions: Query<&Interaction, (Changed<Interaction>, With<ThemeStoreCloseButton>)>,
|
||||
keys: Res<ButtonInput<KeyCode>>,
|
||||
screens: Query<Entity, With<ThemeStoreScreen>>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
for interaction in &interactions {
|
||||
if *interaction != Interaction::Pressed {
|
||||
continue;
|
||||
}
|
||||
for entity in &screens {
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
let clicked = interactions.iter().any(|i| *i == Interaction::Pressed);
|
||||
let esc = keys.just_pressed(KeyCode::Escape) && !screens.is_empty();
|
||||
if !clicked && !esc {
|
||||
return;
|
||||
}
|
||||
for entity in &screens {
|
||||
commands.entity(entity).despawn();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user