fix(forms): reset replacement sessions and preserve visible scroll

This commit is contained in:
Codex
2026-09-11 08:33:06 -07:00
parent 8895dd2e0f
commit 80f2588214
10 changed files with 395 additions and 44 deletions
@@ -232,25 +232,31 @@ impl Operation for Collect {
};
let mut shifts = BTreeMap::new();
for ancestor in ancestors.iter().rev() {
let dx = reveal(
bounds.x,
bounds.width,
ancestor.bounds.x,
ancestor.bounds.width,
);
let dy = reveal(
bounds.y,
bounds.height,
ancestor.bounds.y,
ancestor.bounds.height,
);
// Drawing offsets are rounded; an already-visible axis must not
// acquire a scroll delta from a fractional capacity alone.
let delta = Vector::new(
(ancestor.offset.x
+ reveal(
bounds.x,
bounds.width,
ancestor.bounds.x,
ancestor.bounds.width,
))
.clamp(0., ancestor.capacity.x)
- ancestor.offset.x,
(ancestor.offset.y
+ reveal(
bounds.y,
bounds.height,
ancestor.bounds.y,
ancestor.bounds.height,
))
.clamp(0., ancestor.capacity.y)
- ancestor.offset.y,
if dx == 0. {
0.
} else {
(ancestor.offset.x + dx).clamp(0., ancestor.capacity.x) - ancestor.offset.x
},
if dy == 0. {
0.
} else {
(ancestor.offset.y + dy).clamp(0., ancestor.capacity.y) - ancestor.offset.y
},
);
if delta != Vector::ZERO {
shifts.insert(ancestor.index, delta);
@@ -1,7 +1,7 @@
//! Scenario presentation. Layout/camera controls never construct model commands.
use super::super::scenario_scroll;
use super::super::{form_session, scenario_scroll};
use super::*;
use iced::widget::{Space, column, keyed_column, sensor};
use iced::widget::{Space, column, sensor};
pub(crate) const NAME_INPUT: &str = "scenario-form-name";
@@ -754,16 +754,13 @@ fn editor_panel<'a, R: iced::advanced::text::Renderer + 'a>(
container(
column![
container(actions).id("scenario-actions").width(Fill),
keyed_column([(
form_session::reset_on_change(
session,
scrollable(fields)
.id("scenario-form")
.width(Fill)
.height(Fill)
.into(),
)])
.width(Fill)
.height(Fill),
.height(Fill),
),
]
.spacing(6),
)