Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Commit

Permalink
Fix bug for slug field when no label element with attribute for=title…
Browse files Browse the repository at this point in the history
… exists
  • Loading branch information
eleriojavere committed Mar 22, 2021
1 parent 337aa7b commit 5a49c47
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/js/nova-blog-dist.js

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions resources/slug-field/components/SlugField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,8 @@ export default {
: 'x',
};
String.prototype.latinise = function() {
return this.replace(/[^A-Za-z0-9\[\] ]/g, function(a) {
String.prototype.latinise = function () {
return this.replace(/[^A-Za-z0-9\[\] ]/g, function (a) {
return Latinise.latin_map[a] || a;
});
};
Expand Down Expand Up @@ -917,19 +917,21 @@ export default {
autoFillFromTitle() {
// Find the correct field based on the label
const titleContainer = document.querySelector('label[for="title"]').parentElement.parentElement;
if (document.querySelector('label[for="title"]')) {
const titleContainer = document.querySelector('label[for="title"]').parentElement.parentElement;
// We support titles which are markdown textareas, or titles, so we look for both
// Codemirror creates two textareas, so we look for the one with tabindex which is the one that receives user input
const inputElement =
titleContainer.querySelector('textarea[tabindex="0"]') ||
titleContainer.querySelector('#title') ||
titleContainer.querySelector('.trix-content');
// We support titles which are markdown textareas, or titles, so we look for both
// Codemirror creates two textareas, so we look for the one with tabindex which is the one that receives user input
const inputElement =
titleContainer.querySelector('textarea[tabindex="0"]') ||
titleContainer.querySelector('#title') ||
titleContainer.querySelector('.trix-content');
if (!inputElement) return;
if (!inputElement) return;
inputElement.addEventListener('input', evt => this.updateTitle(titleContainer));
inputElement.addEventListener('keyup', evt => this.updateTitle(titleContainer));
inputElement.addEventListener('input', (evt) => this.updateTitle(titleContainer));
inputElement.addEventListener('keyup', (evt) => this.updateTitle(titleContainer));
}
},
},
};
Expand Down

0 comments on commit 5a49c47

Please sign in to comment.