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

fix(datetime): scroll to newly selected date when value changes #27806

Merged
merged 50 commits into from
Aug 23, 2023
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ce4c2eb
always jump to selected month when value changes
Jul 14, 2023
39d6871
remove remaining activePartsClone refs
Jul 14, 2023
5c13d59
add ability to animate smoothly to month of new value (needs cleanup …
Jul 17, 2023
e6a9ed5
remove DatetimeMonth interface and include day when forcing month
Jul 18, 2023
5ae63ec
rename state variable to use date instead of month
Jul 18, 2023
27d76c7
remove missed instance of manually getting forced day
Jul 18, 2023
237f015
nevermind this totally works, was jumping to another year lol
Jul 18, 2023
e79a558
actually wait for next/prevMonth call to finish before unsetting forc…
Jul 18, 2023
59e0bde
remove console logs
Jul 18, 2023
db126be
check if we actually scrolled to the forced month before returning it
Jul 18, 2023
2877537
pull grid style check into private getter
Jul 18, 2023
21e3648
remove unused variables
Jul 18, 2023
f90bcc4
don't animate if in closed datetime-button
Jul 18, 2023
79b8e92
switch lock promise to a local variable
Jul 18, 2023
69267e4
more comments
Jul 18, 2023
ab9bf27
lint
Jul 18, 2023
cbfc8e9
add tests
Jul 19, 2023
4cf6270
Merge branch 'feature-7.3' into FW-3846
averyjohnston Jul 19, 2023
fd9508e
await processValue in places it was already being called
Jul 24, 2023
10b70ed
tweak variable name to match language
Jul 24, 2023
dda4f0b
clean up promise typing
Jul 24, 2023
7a3f927
don't animate if month/year picker is open
Jul 24, 2023
3dd1732
fix error when setting value to improperly formatted string
Jul 24, 2023
607f43c
handle improper date formatting for multiple values
Jul 24, 2023
c57c6fe
update parseDate type sigs to include returning undefined when val co…
Jul 24, 2023
f3679c1
fix min/max parsing erroring out if year isn't provided
Jul 24, 2023
3fe32dc
lint
Jul 24, 2023
53e288e
avoid crash when manually setting value to empty array
Jul 24, 2023
692a270
fix month scroll breaking when value is changed with time popover open
Jul 25, 2023
17224a1
use undefined instead of null for forceRenderDate
Aug 1, 2023
a077005
re-use current date in both branches of generateMonths
Aug 1, 2023
bf67e71
remove animate param from processValue
Aug 1, 2023
07426c6
set forceRenderDate to whole targetValue for consistency
Aug 1, 2023
d2cd559
also match isBefore language in generateMonths
Aug 1, 2023
aa9d1da
lint
Aug 1, 2023
24061b6
Merge branch 'feature-7.3' into FW-3846
averyjohnston Aug 1, 2023
cf4128f
try adding animate param back in but also animating when calling reset
Aug 1, 2023
5c842cf
check if calendar body is ready before animating; take animate param …
Aug 3, 2023
90a92d1
always assume we've scrolled to the forced date if it's set
Aug 4, 2023
bf0fc24
fix forceRenderDate comment
Aug 4, 2023
50703df
pull scroll waiting stuff into separate method so processValue can be…
Aug 4, 2023
8936c02
lint
Aug 4, 2023
cb3f835
Merge remote-tracking branch 'origin/feature-7.3' into FW-3846
Aug 4, 2023
b1ccb75
remove unneeded manual month/year selection from test
Aug 4, 2023
fbf2f9c
don't animate if target month and/or year are undefined
Aug 8, 2023
b85c7df
combine didChangeMonth and monthYearDefined conditions
Aug 8, 2023
3d79ec9
add isGridStyle to destructure from `this`
Aug 21, 2023
419b12a
Merge branch 'feature-7.4' into FW-3846
Aug 21, 2023
129b370
lint
Aug 21, 2023
d884163
Merge branch 'feature-7.4' into FW-3846
averyjohnston Aug 23, 2023
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
Prev Previous commit
Next Next commit
check if we actually scrolled to the forced month before returning it
amandaesmith3 committed Jul 18, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit db126befa68931aa2232cbc610e6cf7c1bb50347
15 changes: 13 additions & 2 deletions core/src/components/datetime/datetime.tsx
Original file line number Diff line number Diff line change
@@ -862,9 +862,20 @@ export class Datetime implements ComponentInterface {
const monthBox = month.getBoundingClientRect();
if (Math.abs(monthBox.x - box.x) > 2) return;

// TODO: also check if we actually scrolled to the forced month, for safety
/**
* If we're force-rendering a month, and we've scrolled to
* that month, return that.
*
* Checking that we've actually scrolled to the forced month
* is mostly for safety; in theory, if there's a forced month,
* that means a new value was manually set, so we should have
* automatically animated directly to it.
*/
const { forceRenderDate } = this;
if (forceRenderDate !== null) {
const firstDayEl = month.querySelector('.calendar-day');
const dataMonth = firstDayEl?.getAttribute('data-month');
const dataYear = firstDayEl?.getAttribute('data-year');
if (forceRenderDate !== null && dataMonth && dataYear && parseInt(dataMonth) === forceRenderDate.month && parseInt(dataYear) === forceRenderDate.year) {
return { month: forceRenderDate.month, year: forceRenderDate.year, day: forceRenderDate.day };
liamdebeasi marked this conversation as resolved.
Show resolved Hide resolved
}