[FIX] website: trim SEO Keywords in SEO Dialog
In 15.0, the SEO dialog did not allow trailing/leading spaces. However, in Odoo 16.0 one can add leading and trailing spaces in their SEO keywords. This is becausethe commit which converted the SEO dialog to OWL [1] did not trim new keywords, which could lead to keywords with trailing space. It means that those keyword won't be marked as checked in the SEO Dialog. This commit removes trailing spaces when opening the SEO Dialog, in case of an existing DB having such a case, and also when adding new keywords. To note that trailing spaces will still be inside the page until the SEO dialog saves the SEO data again. Note that there might be (or might have been at some point) some cases of migration which seems to lead to those spaces being added when the user land in Odoo 16. [1]: https://github.com/odoo/odoo/commit/ac55f2bb113ecf7c774fe6e96d28e716184a97d1 opw-3460300 closes odoo/odoo#138872 X-original-commit: 69c0293b59468c24c92b8b900cba7dd93bbbd0cf Signed-off-by: Romain Derie (rde) <rde@odoo.com> Signed-off-by: Arthur Detroux (ard) <ard@odoo.com>
This commit is contained in:
committed by
Romain Derie
parent
85ac46e9f1
commit
abe7f88a8b
@@ -228,6 +228,7 @@ class MetaKeywords extends Component {
|
||||
}
|
||||
|
||||
addKeyword(keyword) {
|
||||
keyword = keyword.trim();
|
||||
if (keyword && !this.isFull && !this.seoContext.keywords.includes(keyword)) {
|
||||
this.seoContext.keywords.push(keyword);
|
||||
this.state.keyword = '';
|
||||
@@ -433,8 +434,10 @@ export class OptimizeSEODialog extends Component {
|
||||
}
|
||||
const el = this.pageDocumentElement.querySelector(query);
|
||||
if (name === 'keywords') {
|
||||
const parsed = el && el.content.split(',');
|
||||
return parsed && parsed[0] ? parsed : [];
|
||||
// Keywords might contain spaces which makes them fail the content
|
||||
// check. Trim the strings to prevent this from happening.
|
||||
const parsed = el && el.content.split(',').map(kw => kw.trim());
|
||||
return parsed && parsed[0] ? [...new Set(parsed)] : [];
|
||||
}
|
||||
return el && el.content;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user