mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
🐛 Fixed tag slug not auto-matching tag title when creating new tag
refs 08b099e527
- when the use of scratch values was removed a bug was introduced where only the first character of the tag title was used to set the slug when typing
- bug was caused because previously we were checking against the original `tag.slug` value which wouldn't have been set yet because we were setting scratch values instead
- updated the code to explicitly mark the slug value as being set manually if it's edited directly so the auto-update logic can use that to skip updates instead of comparing against old/unset values
This commit is contained in:
parent
04dfa0a9e5
commit
79d8e64e9a
@ -117,10 +117,8 @@ export default class TagForm extends Component {
|
||||
newValue = newValue.trim();
|
||||
}
|
||||
|
||||
tag[property] = newValue;
|
||||
|
||||
// Generate slug based on name for new tag when empty
|
||||
if (property === 'name' && !tag.slug && tag.isNew) {
|
||||
if (property === 'name' && tag.isNew && !this.hasChangedSlug) {
|
||||
let slugValue = slugify(newValue);
|
||||
if (/^#/.test(newValue)) {
|
||||
slugValue = 'hash-' + slugValue;
|
||||
@ -128,6 +126,13 @@ export default class TagForm extends Component {
|
||||
tag.slug = slugValue;
|
||||
}
|
||||
|
||||
// ensure manual changes of slug don't get reset when changing name
|
||||
if (property === 'slug') {
|
||||
this.hasChangedSlug = !!newValue;
|
||||
}
|
||||
|
||||
tag[property] = newValue;
|
||||
|
||||
// clear validation message when typing
|
||||
tag.hasValidated.addObject(property);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user