Skip to content
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

LG-3896, LG-3898: Date Picker input selection #2186

Merged
merged 36 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
716f099
wip
shaneeza Jan 25, 2024
d7ebcfa
wip - on click
shaneeza Jan 25, 2024
2e33e15
fix to only delete if its a number
shaneeza Jan 25, 2024
bff84a5
comment
shaneeza Jan 26, 2024
707524d
switch to HTMLInputElement
shaneeza Jan 26, 2024
e6b97d6
change back to HTMLElement
shaneeza Jan 26, 2024
f77b235
wip updating tests
shaneeza Jan 30, 2024
015bd08
wip, tests
shaneeza Jan 30, 2024
cba99bd
wip - testing onChange
shaneeza Jan 30, 2024
8305c83
dont propagate up when the backspace clears a value
shaneeza Jan 30, 2024
77587a4
a little clean up, needs more
shaneeza Jan 30, 2024
1441531
some more cleanup
shaneeza Jan 30, 2024
620c1b7
remove comments
shaneeza Jan 30, 2024
9f68176
comment
shaneeza Jan 30, 2024
b4b8ec8
add changeset
shaneeza Jan 30, 2024
8b3f4d8
Merge branch 'main' of github.com:mongodb/leafygreen-ui into LG-3896-…
shaneeza Jan 30, 2024
4824a8b
wip - addressing comments
shaneeza Feb 2, 2024
cbc1aaf
Merge branch 'main' of github.com:mongodb/leafygreen-ui into LG-3896-…
shaneeza Feb 2, 2024
374bbe2
more feedback
shaneeza Feb 2, 2024
6962167
remove only
shaneeza Feb 2, 2024
6e03eb6
wip
shaneeza Feb 6, 2024
d5c6635
Merge branch 'main' of github.com:mongodb/leafygreen-ui into LG-3896-…
shaneeza Feb 14, 2024
29358b5
revert Typo change
shaneeza Feb 14, 2024
626d53f
some feedback
shaneeza Feb 14, 2024
8963d76
wip
shaneeza Feb 15, 2024
c383103
remove comments
shaneeza Feb 15, 2024
9c7858e
fix failing tests, still wip
shaneeza Feb 15, 2024
5c8512b
update test
shaneeza Feb 15, 2024
9c6e552
update tests
shaneeza Feb 16, 2024
2f491c5
Merge branch 'main' of github.com:mongodb/leafygreen-ui into LG-3896-…
shaneeza Feb 16, 2024
38945f4
update changeset
shaneeza Feb 16, 2024
cf2c541
changeset updates
shaneeza Feb 16, 2024
0a3ed89
more changeset changes
shaneeza Feb 16, 2024
4619910
comments
shaneeza Feb 16, 2024
0824bfc
clean up tests
shaneeza Feb 16, 2024
38f15d8
feedback
shaneeza Feb 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .changeset/eight-beds-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
'@leafygreen-ui/date-picker': major
---

Changes the behavior of segments.

## Backspace

### New Behavior
- Pressing `backspace` will always clear the segment and keep the focus on that segment
- Pressing `backspace` twice will clear the segment and move the focus to the previous segment

### Old Behavior
- Pressing `backspace` deletes characters before the cursor one by one
- After all characters are deleted, the focus moves to the previous segment

## Space

### New Behavior
- Pressing `space` will always clear the segment and keep the focus on that segment

### Old Behavior
- Pressing `space` does not change the current value

## Clicking

### New Behavior
#### When initially clicking on a segment with a value, the segment will select the value:
- Typing a digit will clear the segment and populate the segment with that new value.
- Pressing the `backspace` key will clear the segment
- Pressing the `backspace` key twice will clear the segment and move the focus to the previous segment
- Pressing the `space` key will clear the segment

#### When initially clicking on a segment without a value, the segment will show a cursor:
- Typing a digit will start to populate the segment
- Pressing the `backspace` key will move the focus to the previous segment
- Pressing the `space` key will keep the focus on that segment

#### When a segment is already selected, clicking on the segment a second time will deselect the segment, and a cursor will appear:
- Typing a digit will clear the segment and populate the segment with that new value.
- Pressing the `backspace` key will clear the segment
- Pressing the `backspace` key twice will clear the segment and move the focus to the previous segment
- Pressing the `space` key will clear the segment

### Old Behavior
- Clicking on a segment will make the cursor appear in the clicked spot.
- If the segment is full, typing will not change the value
- If the segment is not full, typing will not add a new character after the cursor

## Tabbing and Left/Right arrows

### New behavior
#### When when using the arrow keys or tabbing into a segment with a value, the segment will select the value:
- Typing a digit will reset the segment and populate the segment with that new value.
- Pressing the `backspace` key will clear the segment
- Pressing the `backspace` key twice will clear the segment and move the focus to the previous segment
- Pressing the `space` key will clear the segment

#### When using the arrow keys or tabbing into a segment without a value, the segment will show a cursor:
- Typing a digit will start to populate the segment
- Pressing the `backspace` key will move the focus to the previous segment
- Pressing the `space` key will keep the focus on that segment

## Tabbing
### Old Behavior
- Tabbing into a segment will select the value, but pressing `space` does not reset the value

## Left/Right arrows
### Old Behavior
- When in a segment, `left` or `right` arrow keys navigates through each character instead of selecting the value.
- If the segment is full, typing does not update the value
- If the segment is not full, typing will add a new character in that spot
6 changes: 5 additions & 1 deletion packages/date-picker/src/DatePicker.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const LiveExample: StoryFn<typeof DatePicker> = props => {
onDateChange={v => {
// eslint-disable-next-line no-console
console.log('Storybook: onDateChange', {
value: v!.toUTCString(),
value: v?.toUTCString(),
'value with local browser timezone': v,
});
setValue(v);
Expand All @@ -123,6 +123,10 @@ export const LiveExample: StoryFn<typeof DatePicker> = props => {
'date with local browser timezone': date,
})
}
onChange={e =>
// eslint-disable-next-line no-console
console.log('Storybook: onChange🚨', { value: e.target.value })
}
/>
<br />
<Overline>Current value</Overline>
Expand Down
Loading
Loading