From 3761d35ea5c62d276a96ea803f61b59dfbe9bd38 Mon Sep 17 00:00:00 2001 From: Benjamin Klaus Date: Wed, 7 Feb 2024 14:31:13 +0100 Subject: [PATCH] fixed broken "toggleInBar" if there are more than 1 actions of type GridActionWordForm, #254 --- src/js/service/collectElementService.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/src/js/service/collectElementService.js b/src/js/service/collectElementService.js index 305a386a1..f829fde58 100644 --- a/src/js/service/collectElementService.js +++ b/src/js/service/collectElementService.js @@ -277,6 +277,13 @@ function getActionOfType(elem, type) { return elem.actions[index]; } +function getActionsOfType(elem, type) { + if (!elem) { + return []; + } + return elem.actions.filter(action => action.modelName === type); +} + function getActionTypes(elem) { return elem.actions.map((action) => action.modelName); } @@ -521,6 +528,14 @@ $(window).on(constants.ELEMENT_EVENT_ID, function (event, element) { if (getActionTypes(element).some((type) => ignoreActions.includes(type))) { return; // dont collect elements containing "ignoreActions" } + let navigateAction = getActionOfType(element, GridActionNavigate.getModelName()); + if (navigateAction && getLabel(element).length !== 1 && !navigateAction.addToCollectElem) { + return; // no adding of text if the element contains an navigate action and it's no single keyboard character + } + let wordFormActions = getActionsOfType(element, GridActionWordForm.getModelName()); + if (wordFormActions.length > 0 && wordFormActions.some(a => a.type === GridActionWordForm.WORDFORM_MODE_NEXT_FORM)) { + return; // no adding, since the action itself adds the element + } if (element.dontCollect) { return; } @@ -532,14 +547,6 @@ $(window).on(constants.ELEMENT_EVENT_ID, function (event, element) { return; } } - let navigateAction = getActionOfType(element, GridActionNavigate.getModelName()); - if (navigateAction && getLabel(element).length !== 1 && !navigateAction.addToCollectElem) { - return; // no adding of text if the element contains an navigate action and it's no single keyboard character - } - let wordFormAction = getActionOfType(element, GridActionWordForm.getModelName()); - if (wordFormAction && wordFormAction.type === GridActionWordForm.WORDFORM_MODE_NEXT_FORM) { - return; // no adding, since the action itself adds the element - } if (element.type === GridElement.ELEMENT_TYPE_NORMAL) { element.wordFormTags = stateService.getCurrentWordFormTags();