You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR fixesthis issue regarding unexpected behaviour when typing into a date field.
This can be broken down into three fixes:
Firstly, pressing backspace when the year segment only had one character caused the entire date to be cleared, frustratingly meaning the user had to enter the day and month again. We now have a private #segmentClearedValue variable which is used to specify whether the segment was cleared by the user, in which case we should not clear the whole input. This method ensures if this code is triggered from anywhere else its behaviour is unchanged.
Secondly, there was an issue regarding when to move to the next segment when backspace had been used. The existing implementation thinks you should move forward after typing enough characters to match the number of backspaces, however this causes an issue when someone makes a typo. e.g. if someone makes a mistake at the start of entering the year and they type 1, Backspace, 2 the focus will jump to the next segment before the user gets a chance to type the rest of the year. This fix now sticks with the same segment until that segment is completed.
Thirdly, there were issues stemming from padding incomplete segments with preceding zeros. These zeros were then treated as part of the segment's value, which caused confusion when completing or editing a segment, particularly noticeable when backspacing in the year segment. This fix uses integer division to remove the last character and then reapplies the padding before it is shown. This ensures the full padding is always shown to the user but the preceding zeros don't impact the backspace process.
The should handle backspacing the year segment appropriately date-field test has also been updated to reflect the new behaviour.
This has been tested manually, and tests have been run to confirm the only failures were pre-existing.
If there are any changes you'd like, please let me know!
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Hi! It looks like this PR hasn’t seen any activity for a while. I was interested in working on this issue as well and would be happy to take this up and address the CI failures in a new PR, if that’s okay. Please let me know.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This PR fixes this issue regarding unexpected behaviour when typing into a date field.
This can be broken down into three fixes:
Firstly, pressing backspace when the year segment only had one character caused the entire date to be cleared, frustratingly meaning the user had to enter the day and month again. We now have a private
#segmentClearedValuevariable which is used to specify whether the segment was cleared by the user, in which case we should not clear the whole input. This method ensures if this code is triggered from anywhere else its behaviour is unchanged.Secondly, there was an issue regarding when to move to the next segment when backspace had been used. The existing implementation thinks you should move forward after typing enough characters to match the number of backspaces, however this causes an issue when someone makes a typo. e.g. if someone makes a mistake at the start of entering the year and they type
1,Backspace,2the focus will jump to the next segment before the user gets a chance to type the rest of the year. This fix now sticks with the same segment until that segment is completed.Thirdly, there were issues stemming from padding incomplete segments with preceding zeros. These zeros were then treated as part of the segment's value, which caused confusion when completing or editing a segment, particularly noticeable when backspacing in the year segment. This fix uses integer division to remove the last character and then reapplies the padding before it is shown. This ensures the full padding is always shown to the user but the preceding zeros don't impact the backspace process.
The
should handle backspacing the year segment appropriatelydate-field test has also been updated to reflect the new behaviour.This has been tested manually, and tests have been run to confirm the only failures were pre-existing.
If there are any changes you'd like, please let me know!