Skip to content

Commit

Permalink
fixed broken "toggleInBar" if there are more than 1 actions of type G…
Browse files Browse the repository at this point in the history
…ridActionWordForm, #254
  • Loading branch information
klues committed Feb 7, 2024
1 parent 99db82e commit 3761d35
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/js/service/collectElementService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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();
Expand Down

0 comments on commit 3761d35

Please sign in to comment.