diff --git a/client/src/state/app/state.rs b/client/src/state/app/state.rs index f6d9882..8cb8440 100644 --- a/client/src/state/app/state.rs +++ b/client/src/state/app/state.rs @@ -113,6 +113,13 @@ impl AppState { false } + pub fn is_canvas_edit_mode_at(&self, path: &str) -> bool { + self.form_editor + .get(path) + .map(|e| matches!(e.mode(), canvas::AppMode::Edit)) + .unwrap_or(false) + } + // Mutable editor accessor pub fn editor_for_path(&mut self, path: &str) -> Option<&mut FormEditor> { self.form_editor.get_mut(path) diff --git a/client/src/ui/handlers/render.rs b/client/src/ui/handlers/render.rs index 157584c..3bff7cb 100644 --- a/client/src/ui/handlers/render.rs +++ b/client/src/ui/handlers/render.rs @@ -151,12 +151,13 @@ pub fn render_ui( } else { (0, 1) }; + let table_name = path.split('/').nth(1).unwrap_or(""); render_form_page( f, form_render_area, editor, - app_state.current_view_table_name.as_deref().unwrap_or(""), + table_name, theme, total_count, current_position, diff --git a/client/src/ui/handlers/ui.rs b/client/src/ui/handlers/ui.rs index 3032c0d..5d0a315 100644 --- a/client/src/ui/handlers/ui.rs +++ b/client/src/ui/handlers/ui.rs @@ -446,6 +446,9 @@ pub async fn run_ui() -> Result<()> { AppView::AddLogic => router.navigate(Page::AddLogic(admin_state.add_logic_state.clone())), AppView::Form(path) => { // Router now carries the path; just navigate with it + if let Some((profile, table)) = path.split_once('/') { + app_state.set_current_view_table(profile.to_string(), table.to_string()); + } router.navigate(Page::Form(path.clone())); } AppView::Scratch => {} @@ -610,7 +613,7 @@ pub async fn run_ui() -> Result<()> { if let Page::Form(path) = &router.current { if !table_just_switched { - if position_changed && !app_state.is_canvas_edit_mode() { + if position_changed && !app_state.is_canvas_edit_mode_at(path) { position_logic_needs_redraw = true; if let Some(form_state) = app_state.form_state_for_path(path) { @@ -648,7 +651,7 @@ pub async fn run_ui() -> Result<()> { form_state.current_cursor_pos = event_handler.ideal_cursor_column.min(max_cursor_pos); } - } else if !position_changed && !app_state.is_canvas_edit_mode() { + } else if !position_changed && !app_state.is_canvas_edit_mode_at(path) { if let Some(form_state) = app_state.form_state_for_path(path) { let current_input_str = form_state.get_current_input(); let current_input_len = current_input_str.chars().count();