Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Keep highlighting of invalid tokens on focus

Jan Sandbrinkf78004a6a12c
diff --git a/frontend/src/stimulus/controllers/pattern-input.controller.ts b/frontend/src/stimulus/controllers/pattern-input.controller.ts
index 854398856a6..faa1c3be923 100644
--- a/frontend/src/stimulus/controllers/pattern-input.controller.ts
+++ b/frontend/src/stimulus/controllers/pattern-input.controller.ts
@@ -466,9 +466,7 @@ export default class PatternInputController extends Controller {
private tagInvalidTokens():void {
this.contentTarget.querySelectorAll('[data-role="token"]').forEach((element:TokenElement) => {
- const exists = Object.keys(this.validTokenMap).some((key) => this.validTokenMap[key].enabled && key === element.dataset.prop);
-
- if (exists) {
+ if (this.isSuggestable(element.dataset.prop)) {
this.setStyle(element, 'accent');
} else {
this.setStyle(element, 'danger');
@@ -476,6 +474,10 @@ export default class PatternInputController extends Controller {
});
}
+ private isSuggestable(token:string):boolean {
+ return Object.keys(this.validTokenMap).some((key) => this.validTokenMap[key].enabled && token === key);
+ }
+
private setStyle(token:TokenElement, style:'accent'|'danger'|'secondary'):void {
switch (style) {
case 'accent':
@@ -506,9 +508,13 @@ export default class PatternInputController extends Controller {
private sanitizeContent():void {
this.contentTarget.childNodes.forEach((node) => {
if (this.isToken(node)) {
- this.setStyle(node, 'accent');
-
const key = node.dataset.prop;
+ if(this.isSuggestable(key)) {
+ this.setStyle(node, 'accent');
+ } else {
+ this.setStyle(node, 'danger');
+ }
+
if (node.textContent !== this.tokenText(key)) {
if (this.containsCursor(node)) {
this.setStyle(node, 'secondary');