Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Crash When Deselecting Layer While Editing Properties #665

Merged
merged 1 commit into from
Jun 7, 2022
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: 10 additions & 2 deletions editor/src/layout/layout_message_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,17 @@ impl MessageHandler<LayoutMessage, ()> for LayoutMessageHandler {
}
UpdateLayout { layout_target, widget_id, value } => {
let layout = &mut self.layouts[layout_target as usize];
let widget_holder = layout.iter_mut().find(|widget| widget.widget_id == widget_id).expect("Received invalid widget_id from the frontend");
let widget_holder = layout.iter_mut().find(|widget| widget.widget_id == widget_id);
if widget_holder.is_none() {
log::trace!(
"Could not find widget_id:{} on layout_target:{:?}. This could be an indication of a problem or just a user clicking off of an actively edited layer",
widget_id,
layout_target
);
return;
}
#[remain::sorted]
match &mut widget_holder.widget {
match &mut widget_holder.unwrap().widget {
Widget::CheckboxInput(checkbox_input) => {
let update_value = value.as_bool().expect("CheckboxInput update was not of type: bool");
checkbox_input.checked = update_value;
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/widgets/inputs/NumberInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export default defineComponent({

this.editing = false;

const inputElement = (this.$refs.fieldInput as typeof FieldInput).$refs.input as HTMLInputElement;
inputElement.blur();
const inputElement = (this.$refs.fieldInput as typeof FieldInput)?.$refs?.input as HTMLInputElement | undefined;
inputElement?.blur();
},
onCancelTextChange() {
this.updateValue(undefined);
Expand Down