Excerpt form error fix (#20730)

fixes
https://linear.app/tryghost/issue/DES-435/excerpt-in-post-settings-has-an-inconsistent-error-state

The excerpt form field seemed to not be properly handling errors.
However, it was a case of the error styling being overruled by the
regular styling, causing the red border to only show upon `:focus` when
there is an error in the excerpt.

I've rewritten the logic to be slightly less obfuscated and added some
CSS to circumvent the issue.
This commit is contained in:
Daniël van der Winden 2024-08-12 11:35:21 +02:00 committed by GitHub
parent 85aed302c1
commit 0412decaec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 6 deletions

View File

@ -225,7 +225,7 @@ select {
.gh-select.error,
.error .gh-input-append,
select.error {
border-color: var(--red);
border-color: var(--red)!important;
}
.gh-input:focus,

View File

@ -62,12 +62,11 @@ export default BaseValidator.create({
customExcerpt(model) {
if (!validator.isLength(model.customExcerpt || '', 0, 300)) {
if (model.feature.editorExcerpt) {
model.errors.add('customExcerpt', 'Excerpt cannot be longer than 300 characters.');
} else {
model.errors.add('customExcerpt', 'Excerpt cannot be longer than 300 characters.');
}
const errorMessage = 'Excerpt cannot be longer than 300 characters.';
model.errors.add('customExcerpt', errorMessage);
this.invalidate();
} else {
model.errors.remove('customExcerpt');
}
},