Repository navigation
fix(TimeInput, DateTimeInput): under a finger the AM/PM wheel follows the hour #8179
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] `clampTime` without seconds now gives the nearest whole minute inside a bound that falls between minutes. Before, `clampTime('08:00', '09:00:30')` gave `09:00`, a time outside the range. | ||
|
|
||
| @vjeux |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [fix] Under a finger, the time wheels in the TimeInput and DateTimeInput bottom sheets now follow iOS's date picker: | ||
|
|
||
| - The AM/PM column follows the hour. Turning the hour from 11 to 12 now gives 12 PM, not 12 AM, and the AM/PM column turns onto PM. From 12 PM to 1 it stays PM. | ||
| - A bound that falls between whole minutes, such as `min="09:00:30"` without a seconds column, now commits the nearest whole minute inside it, with a finger as with a mouse. | ||
|
|
||
| With a mouse, each column still turns on its own. | ||
|
|
||
| @vjeux |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@astryxdesign/core': patch | ||
| --- | ||
|
|
||
| [chore] Internal: the picker wheel turns from script, for the time columns that use it. Under a finger, `spinTo` on the wheel's ref turns it onto a row on the tap spin, then commits it as a rest would; under a fine pointer it commits the row at once. Either way it reports whether that row was committed: it refuses a disabled row and an index outside the rows, and a turn the wheel's unmounting cuts short reports that it did not arrive. Nothing public changes: the wheel is not exported from the package entry point. | ||
|
|
||
| @vjeux |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,8 @@ | |
|
|
||
| /** | ||
| * @file PickerWheel.tsx | ||
| * @input Wheel's props (wheelOptions.ts): options, value and change callback | ||
| * @input Wheel's props (wheelOptions.ts): options, value and change callback; | ||
| * optionally a ref for programmatic turns | ||
| * @output PickerWheel: one picker column that moves like UIPickerView | ||
| * @position Internal component; the Wheel under a finger (Wheel.tsx picks it) | ||
| * | ||
|
|
@@ -15,7 +16,14 @@ | |
| * DateInputTouch.test.tsx, DateInput.doc.mjs and TimeInput.doc.mjs. | ||
| */ | ||
|
|
||
| import {useCallback, useEffect, useMemo, useRef, useState} from 'react'; | ||
| import { | ||
| useCallback, | ||
| useEffect, | ||
| useImperativeHandle, | ||
| useMemo, | ||
| useRef, | ||
| useState, | ||
| } from 'react'; | ||
| import * as stylex from '@stylexjs/stylex'; | ||
| import {scrollTypeOf} from '../gestures/GestureHost'; | ||
| import {PanGestureRecognizer} from '../gestures/PanGestureRecognizer'; | ||
|
|
@@ -50,6 +58,7 @@ import { | |
| type WheelLayout, | ||
| } from './wheelPhysics'; | ||
| import { | ||
| canSpinTo, | ||
| endIndex, | ||
| nearestEnabledIndex, | ||
| steppedIndex, | ||
|
|
@@ -197,6 +206,7 @@ export function PickerWheel({ | |
| value, | ||
| onChange, | ||
| isActive = true, | ||
| ref, | ||
| }: WheelProps) { | ||
| const columnRef = useRef<HTMLDivElement | null>(null); | ||
| const rowsRef = useRef<HTMLDivElement | null>(null); | ||
|
|
@@ -584,6 +594,31 @@ export function PickerWheel({ | |
| isPointerKept: true, | ||
| }); | ||
|
|
||
| // A spin turns only onto an enabled row (canSpinTo). So its arrival commits | ||
| // that row, and nothing turns on past it. It reports the row it was asked | ||
| // for, as the scrolling column does. | ||
|
Comment on lines
+597
to
+599
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Optional (comment accuracy): // A spin turns only onto an enabled row (canSpinTo). So its arrival commits
// that row, and nothing turns on past it. It resolves true only when it
// arrives on that row, as the scrolling column does. |
||
| const spinTo = useCallback( | ||
| async (index: number): Promise<boolean> => | ||
| new Promise(resolve => { | ||
| if (!canSpinTo(latestRef.current.options, index)) { | ||
| resolve(false); | ||
| return; | ||
| } | ||
| const offset = motion.offset(); | ||
| move(turnCurve(columnRef.current, offset, index * ROW_HEIGHT), { | ||
| onEnd: (outcome, end) => { | ||
| if (outcome === 'arrived') { | ||
| arrive(end); | ||
| } | ||
| resolve(outcome === 'arrived'); | ||
| }, | ||
| }); | ||
| }), | ||
| [motion, move, arrive], | ||
| ); | ||
|
|
||
| useImperativeHandle(ref, () => ({spinTo}), [spinTo]); | ||
|
|
||
| const turnToPosition = useCallback( | ||
| (position: number, offset: number) => { | ||
| const current = latestRef.current; | ||
|
|
||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Non-blocking:
spinToresolves a boolean, not a row. Suggested: "It resolves true only when it arrives on that row, as the scrolling column does."