Skip to content

Conversation

@alexangelov14
Copy link
Collaborator

These are changes for issue #701

Updated as requested in issue #701
Now it will properly update the last added verb in the collect bar
@alexangelov14 alexangelov14 requested a review from klues December 17, 2025 22:58
@github-actions
Copy link

🎉 Beta deployment successful!: view the changes in live preview environment: https://gridbeta-github.asterics-foundation.org/alexangelov14/-701-word-forms-change-in-collect-element-issue/pr

Copy link
Contributor

@klues klues left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! 👍
Please see my comments.

case GridActionWordForm.WORDFORM_MODE_CHANGE_BAR:
collectElementService.addWordFormTagsToLast(action.tags);
stateService.resetWordFormIds(gridElement);
stateService.addWordFormTags(action.tags, action.toggle);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why we need stateService.resetWordFormIds and stateService.addWordFormTags here? Honestly I cannot really remember exactly what they are doing, but from my current logic, should'nt it be enough to have the adaption in collectElementService.addWordFormTagsToLast() below?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically its enough but with the change in my opinion its better, because what it changes is the following (will show an example):
The user chooses first "I" then wants to change "be" to "am". How it was before you should've pressed first "be" for it to be added to the collection then press "1.PERS" to make it to "am". Also the element itself always stays as "be". If the user presses the "1.PERS" element while nothing is in the collection bar they might start wondering what that even does as its not reflected anywhere else. Personally i don't think that is a great user experience (of course thats up for a discussion). With the current change it goes like this. The user chooses first "I" then wants to change "be" to "am". Now he will first press the "1.PERS" then he will see how the element itself changes to "am" and can decide if thats the right choice before pressing it. After the user presses the now changed "be" to "am" element it will be added to the collection bar as "am" and it will revert itself back to the normal "be" on the element. Hope that clears it out.

collectElementService.addWordFormTagsToLast = function (tags, toggle, skipLast) {
// If skipLast is true, update the second-to-last element instead of the last one
// This is useful when the triggering element was just added to the collect bar
let targetIndex = skipLast ? collectedElements.length - 2 : collectedElements.length - 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should use a different approach here. maybe add some param like skipElementId and then pass gridElement.id when calling the method. Then use the last element of the collected elements which has not the ID of skipElementId. The result will be the same, but the approach is more robust, since it doesn't depend on the order of execution. This solution now only works, if the new element was already added at this point (which seems to be the case right now), but not if it would be added after executing this function. Since it's just chance that the code is executed in this order right now and it's not guaranteed to stay the same forever, the other approach with skipElementId would be more robust and would still work, if code execution order changes for any reason in the future.

@github-actions
Copy link

github-actions bot commented Jan 8, 2026

🎉 Beta deployment successful!: view the changes in live preview environment: https://gridbeta-github.asterics-foundation.org/alexangelov14/-701-word-forms-change-in-collect-element-issue/pr

@alexangelov14
Copy link
Collaborator Author

@klues i added the changes requested in the second comment. You can check it out.

https://gridbeta-github.asterics-foundation.org/alexangelov14/-701-word-forms-change-in-collect-element-issue/pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants