Skip to content

[6.x] Fix validation rules being lost when saving without pressing enter - #15022

Merged
jasonvarga merged 1 commit into
statamic:6.xfrom
mynetx:fix/validation-rule-lost-on-blur
Jul 16, 2026
Merged

[6.x] Fix validation rules being lost when saving without pressing enter#15022
jasonvarga merged 1 commit into
statamic:6.xfrom
mynetx:fix/validation-rule-lost-on-blur

Conversation

@mynetx

@mynetx mynetx commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

When you add a parameterized validation rule (like after:{this}.start_time) and click Save without pressing enter first, the typed rule is silently dropped. The toast says "Saved" but the rule never reaches the YAML. Reported with {this} but it affects any rule entered through the parameter input.

The input commits its value on blur, but listeners passed to the Input component land on its outer wrapper via attribute fallthrough, and blur doesn't bubble, so the handler never fired. Enter worked because keydown does bubble up to the wrapper. Switching to focusout commits the rule on the way out, whichever way you leave the field. The two ref focus calls are optional-chained since focusout can also fire while the field settings stack is closing.

Worth noting: the underlying component behavior (non-bubbling listeners passed to Input never fire) still exists and also affects the focus/blur emits of the text-based fieldtypes. Fixing that properly touches the publish field focus handling, so it felt like its own PR rather than a drive-by here.

Fixes #14806

🤖 Generated with Claude Code

The rule builder's parameter input committed its value on blur, but
listeners passed to the Input component land on its outer wrapper via
attribute fallthrough, and blur doesn't bubble, so it never fired.
Clicking Save without pressing enter silently dropped the typed rule.
Use focusout, which bubbles and does reach the wrapper. The ref focus
calls are optional-chained since focusout can also fire while the field
settings stack is closing, after the refs are gone.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@jasonvarga
jasonvarga merged commit 73ceb30 into statamic:6.x Jul 16, 2026
20 checks passed
@mynetx
mynetx deleted the fix/validation-rule-lost-on-blur branch July 16, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't save validation rule with {this} in it

2 participants