-
Notifications
You must be signed in to change notification settings - Fork 42
#701 word forms change in collect element issue #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
#701 word forms change in collect element issue #710
Conversation
Updated as requested in issue #701
Now it will properly update the last added verb in the collect bar
|
🎉 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 |
klues
left a comment
There was a problem hiding this 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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
|
🎉 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 |
|
@klues i added the changes requested in the second comment. You can check it out. |
These are changes for issue #701