ui-contract: a reset of a binding already at its default files no edit

This commit is contained in:
bflatastic
2026-11-22 06:34:35 +07:00
parent 253d76d13f
commit f525fa4e6e
@@ -45,7 +45,8 @@ pub(crate) fn gesture_gate<C: Component>(comp: &C, cx: &mut Cx<'_, C>) {
}
/// Step 9, the edit intents the library takes before `C::update`: Escape or a cancelled press ends a running gesture
/// (Escape as `C::ESCAPE` says), and a reset becomes a `Set` of the binding's reset value.
/// (Escape as `C::ESCAPE` says), and a reset becomes a `Set` of the binding's reset value, unless the value is already
/// that.
pub(crate) fn edit_intents<C: Component>(comp: &mut C, cx: &mut Cx<'_, C>) {
use crate::contract::cx::Edit as _;
if cx.gesture().is_some_and(|phase| matches!(phase, GesturePhase::Begin | GesturePhase::Update)) {
@@ -83,7 +84,9 @@ pub(crate) fn edit_intents<C: Component>(comp: &mut C, cx: &mut Cx<'_, C>) {
};
if let Some(part) = part.filter(|part| cx.core.own_reset_parts.contains(&(part.key, part.index))) {
cx.core.reset_part = Some(part);
} else if let Some(reset) = comp.bind().and_then(|bind| bind.reset_value().cloned()) {
} else if let Some(reset) = comp.bind().and_then(|bind| bind.reset_value().cloned())
&& cx.value() != Some(&reset)
{
cx.set(reset);
}
}