FIO-6578: Fixes an issue with losing focus on Year field when Day component has advanced logic #5301
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Link to Jira Ticket
https://formio.atlassian.net/browse/FIO-6578
Description
Because Day component has three inputs (Day, month and year), formiojs was not able to properly restore focus on it after redrawing, so I adjusted saveCaretPosition function and focus funtion, now it saves field name (day, month or year) instead of input index for Day component and Day component accepts it as an argument to focus a specific field instead of the first one.
This fix is for restoring focus properly on the Day component after redraw, but this issue also was happenning because unneccessary redraws were happenning (Even when nothing has changed after logic ccheck). That was caused by assigning min and maxDate properties to this.component inside get validationValue(). Since it was assigned to the component's schema after constructor has been called, the originalComponent property did not have those properties leading to redrawing component on each logic check. This issue is already fixed on the master branch as part of the other fix. #5024
Dependencies
#5024
How has this PR been tested?
Functionality was tested manually and covered with automated tests as well
Checklist: