Repository navigation
Commit bf0607e
authored
fix(datetime): tear down ready state only when the host is hidden (#31460)
Issue number: resolves #30933
---------
## What is the current behavior?
Currently, an `ion-datetime` in a modal or popover sometimes opens with
a blank calendar on iOS 26. The host is missing `datetime-ready`, so
`.calendar-body` stays at `opacity: 0`. It doesn't happen every time,
and when it does the calendar stays blank until the overlay is reopened.
The `ion-datetime` component runs two IntersectionObservers on the same
root and target, one that adds `datetime-ready` and one that removes it.
WebKit reports an element that is still on screen as not intersecting,
and it doesn't deliver that entry to every observer, so the removing
observer tears the ready state down and the adding one never hears the
recovery.
## What is the new behavior?
The hidden-state observer now checks the host before tearing anything
down. An overlay hides its contents with `display: none`, which leaves
the host without a layout box, so a host that still has one is on screen
and the entry is wrong. The `hasBeenIntersecting` flag added in #31108
is gone, because the same check covers the synthetic "not intersecting"
entry that `observe()` fires when the host mounts offscreen. Both
callbacks also read the last entry instead of the first, since a batched
callback's first entry can be stale.
## Does this introduce a breaking change?
- [ ] Yes
- [X] No
## Other information
I reproduced this on an iOS 26.2 simulator, opening and dismissing the
modal in a loop and checking `datetime-ready` after each open. Four
extra observers on the same root and target recorded 54, 52, 54, 52
events over 25 cycles, which is where the per-observer delivery claim
comes from.
Same machine and everything, 150 cycles each:
| build | blank calendar |
| --- | --- |
| main | 7 (4.7%) |
| this branch | 0 |
The e2e test stubs `IntersectionObserver` to report hidden while the
datetime is on screen, since the WebKit misbehavior can't be forced on
demand. It fails on all three browsers without the fix. The open/close
cycle test guards against regressions but won't reproduce the glitch on
its own.
[Relevant test screen -
iOS](https://ionic-framework-git-fix-30933-ionic1.vercel.app/src/components/datetime-button/test/overlays?ionic:mode=ios)1 parent abc4c6b commit bf0607e
3 files changed
Lines changed: 146 additions & 18 deletions
File tree
- core/src/components
- datetime-button/test/overlays
- datetime
- test/basic
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
270 | 288 | | |
271 | 289 | | |
272 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | 139 | | |
150 | 140 | | |
151 | 141 | | |
| |||
1158 | 1148 | | |
1159 | 1149 | | |
1160 | 1150 | | |
1161 | | - | |
1162 | | - | |
| 1151 | + | |
1163 | 1152 | | |
1164 | 1153 | | |
1165 | 1154 | | |
1166 | 1155 | | |
1167 | 1156 | | |
1168 | 1157 | | |
| 1158 | + | |
| 1159 | + | |
| 1160 | + | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
1169 | 1168 | | |
1170 | 1169 | | |
1171 | 1170 | | |
| |||
1203 | 1202 | | |
1204 | 1203 | | |
1205 | 1204 | | |
1206 | | - | |
| 1205 | + | |
| 1206 | + | |
| 1207 | + | |
| 1208 | + | |
| 1209 | + | |
1207 | 1210 | | |
1208 | 1211 | | |
1209 | 1212 | | |
1210 | 1213 | | |
1211 | | - | |
1212 | 1214 | | |
1213 | 1215 | | |
1214 | 1216 | | |
| |||
1244 | 1246 | | |
1245 | 1247 | | |
1246 | 1248 | | |
1247 | | - | |
| 1249 | + | |
1248 | 1250 | | |
1249 | 1251 | | |
1250 | 1252 | | |
1251 | 1253 | | |
1252 | | - | |
1253 | | - | |
| 1254 | + | |
| 1255 | + | |
| 1256 | + | |
| 1257 | + | |
| 1258 | + | |
| 1259 | + | |
| 1260 | + | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
1254 | 1264 | | |
1255 | 1265 | | |
1256 | | - | |
1257 | 1266 | | |
1258 | 1267 | | |
1259 | 1268 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
491 | 592 | | |
492 | 593 | | |
493 | 594 | | |
| |||
0 commit comments