fix(web): handle the new-from-template file-menu choice (#196)
`FileMenuChoice::NewFromTemplate` was added with the scene-template work
and wired into the native host, but the web host's `match` was left at the
original eight variants. Rust requires exhaustive matches, so op-host-web
stopped compiling under its own feature:
error[E0004]: non-exhaustive patterns:
`FileMenuChoice::NewFromTemplate` not covered
--> crates/op-host-web/src/widget_host/chrome_menu_press.rs:32:78
That breaks `cargo test -p op-host-web --features canvaskit`, which
rust-check.yml runs, and `cargo build --features canvaskit` for the
wasm bundle. The other wasm gates use `--features web`, so nothing else
catches it.
The arm yields `None` rather than a `FileAction`: templates are
desktop-only so far, `FileAction` has no template variant, and the panel
is not wired on web. Returning early instead — as the native host's
equivalent match does — would skip the lines below that close the menu
and clear hover, leaving the menu stuck open on click. `None` dispatches
nothing while still closing the menu, so the row is inert rather than
broken.
This commit is contained in:
parent
15ff2bea43
commit
fd7ebbec7c
|
|
@ -29,16 +29,17 @@ impl WidgetHost {
|
|||
let Some(choice) = menu.choice_for_row(row) else {
|
||||
return;
|
||||
};
|
||||
self.editor_state.editor_ui.pending_file_action = Some(match choice {
|
||||
FileMenuChoice::NewFile => FileAction::New,
|
||||
FileMenuChoice::OpenFile => FileAction::Open,
|
||||
FileMenuChoice::Save => FileAction::Save,
|
||||
FileMenuChoice::SaveAs => FileAction::SaveAs,
|
||||
FileMenuChoice::ExportImage => FileAction::ExportImage,
|
||||
FileMenuChoice::ExportAllFrames => FileAction::ExportAllFrames,
|
||||
FileMenuChoice::OpenRecent(i) => FileAction::OpenRecent(i),
|
||||
FileMenuChoice::ClearRecent => FileAction::ClearRecent,
|
||||
});
|
||||
self.editor_state.editor_ui.pending_file_action = match choice {
|
||||
FileMenuChoice::NewFile => Some(FileAction::New),
|
||||
FileMenuChoice::OpenFile => Some(FileAction::Open),
|
||||
FileMenuChoice::Save => Some(FileAction::Save),
|
||||
FileMenuChoice::SaveAs => Some(FileAction::SaveAs),
|
||||
FileMenuChoice::ExportImage => Some(FileAction::ExportImage),
|
||||
FileMenuChoice::ExportAllFrames => Some(FileAction::ExportAllFrames),
|
||||
FileMenuChoice::OpenRecent(i) => Some(FileAction::OpenRecent(i)),
|
||||
FileMenuChoice::ClearRecent => Some(FileAction::ClearRecent),
|
||||
FileMenuChoice::NewFromTemplate => None, // templates are desktop-only
|
||||
};
|
||||
self.editor_state.editor_ui.file_menu_open = false;
|
||||
self.editor_state.editor_ui.file_menu.hover = None;
|
||||
self.mark_dirty();
|
||||
|
|
|
|||
Loading…
Reference in a new issue