Skip to content

Commit d9c4cd8

Browse files
committed
fix(datetime): improving detection logic
1 parent 212cecf commit d9c4cd8

File tree

2 files changed

+7
-28
lines changed

2 files changed

+7
-28
lines changed

core/src/components/datetime/datetime.scss

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,23 +49,6 @@
4949
width: 100%;
5050
}
5151

52-
/**
53-
* The intersection tracker participates in layout so
54-
* IntersectionObserver has a non-zero rect to observe.
55-
* A negative margin keeps the effective host height
56-
* unchanged so pages embedding ion-datetime (such as
57-
* item input demos) do not grow by 1px.
58-
*/
59-
:host .intersection-tracker {
60-
width: 100%;
61-
height: 1px;
62-
63-
margin-bottom: -1px;
64-
65-
opacity: 0;
66-
pointer-events: none;
67-
}
68-
6952
:host .calendar-body,
7053
:host .datetime-year {
7154
opacity: 0;

core/src/components/datetime/datetime.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,15 +1171,11 @@ export class Datetime implements ComponentInterface {
11711171
* datetime is visible but the host clearly has layout, ensure
11721172
* we still initialize listeners and mark the component as ready.
11731173
*
1174-
* We schedule this a couple of frames after load so that any
1175-
* initial layout/animations (such as a parent modal presenting)
1176-
* have had a chance to run.
1174+
* We schedule this after everything has had a chance to run.
11771175
*/
1178-
raf(() => {
1179-
raf(() => {
1180-
this.ensureReadyIfVisible();
1181-
});
1182-
});
1176+
setTimeout(() => {
1177+
this.ensureReadyIfVisible();
1178+
}, 100);
11831179

11841180
/**
11851181
* We need to clean up listeners when the datetime is hidden
@@ -2704,9 +2700,9 @@ export class Datetime implements ComponentInterface {
27042700
27052701
We can work around this by observing .intersection-tracker and using the host
27062702
(ion-datetime) as the "root". This allows the IO callback to fire the moment
2707-
the datetime is visible. The .intersection-tracker element uses a minimal,
2708-
invisible block size so it participates in layout, and it should not be
2709-
positioned absolutely otherwise the IO callback may fire at unexpected times.
2703+
the datetime is visible. The .intersection-tracker element should not have
2704+
dimensions or additional styles, and it should not be positioned absolutely
2705+
otherwise the IO callback may fire at unexpected times.
27102706
*/}
27112707
<div class="intersection-tracker" ref={(el) => (this.intersectionTrackerRef = el)}></div>
27122708
{this.renderDatetime(mode)}

0 commit comments

Comments
 (0)