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

[4.x] Reveal invalid field on validation error #9577

Merged
merged 6 commits into from
Feb 23, 2024

Conversation

jacksleight
Copy link
Contributor

@jacksleight jacksleight commented Feb 23, 2024

This PR makes a small UX improvement by revealing the first (and most nested) invalid field in the publish form when a validation error occurs, which is particularly useful in large forms with lots of tabs/sets. It will automatically expand sets, activate the right tab then scroll to the field:

CleanShot.2024-02-23.at.15.18.21.mp4

The logic is mostly DOM based with a few hooks into the Vue components to update active/expanded state. It's implemented as a new plugin that can be called via this.$reveal or Statamic.$reveal.

A new global helper function called closestVm is included that will take a DOM node and return the nearest Vue component, optionally matching a specific component name. The replicator and bard set components are now being registered so that they have names, which was required in order to make the lookup work. Additionally a new tab-handle data attribute has been added to tab panel elements in order to make the tab activation simpler.

The feature has been added to the entry, term and user publish forms.

@jasonvarga jasonvarga merged commit 63bbdb4 into statamic:4.x Feb 23, 2024
17 checks passed
@jasonvarga
Copy link
Member

Rad 🤙

@jacksleight jacksleight deleted the feature/reveal-invalid-field branch February 23, 2024 22:50
@duncanmcclean
Copy link
Member

Whoa, this is awesome!

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.

3 participants