Skip to content

Commit 9411756

Browse files
fix(picker-column): fallback to elementFromPoint for iOS 16 Shadow DOM bug
Co-authored-by: Vilhelm Josander <[email protected]>
1 parent d52b253 commit 9411756

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

core/src/components/picker-column/picker-column.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,23 @@ export class PickerColumn implements ComponentInterface {
376376
* elementsFromPoint can returns multiple elements
377377
* so find the relevant picker column option if one exists.
378378
*/
379-
const newActiveElement = elementsAtPoint.find((el) => el.tagName === 'ION-PICKER-COLUMN-OPTION');
379+
let newActiveElement = elementsAtPoint.find((el) => el.tagName === 'ION-PICKER-COLUMN-OPTION');
380+
381+
/**
382+
* TODO(FW-6594): Remove this workaround when iOS 16 is no longer
383+
* supported.
384+
*
385+
* If `elementsFromPoint` failed to find the active element (a known
386+
* issue on iOS 16 when elements are in a Shadow DOM and the
387+
* referenceNode is the document), a fallback to `elementFromPoint`
388+
* is used. While `elementsFromPoint` returns all elements,
389+
* `elementFromPoint` returns only the top-most, which is sufficient
390+
* for this use case and appears to handle Shadow DOM retargeting
391+
* more reliably in this specific iOS bug.
392+
*/
393+
if (!newActiveElement) {
394+
newActiveElement = referenceNode.elementFromPoint(centerX, centerY) as HTMLIonPickerColumnOptionElement;
395+
}
380396

381397
if (activeEl !== undefined) {
382398
this.setPickerItemActiveState(activeEl, false);

0 commit comments

Comments
 (0)