Skip to content

Commit ff2e222

Browse files
committed
fix(core): iOS child index mapping skips the glass effect subview
iosGlassEffect inserts a UIVisualEffectView at subview 0 of the view, so its children live one subview past their child index. The index mapping still passed child indices through unchanged, and a child inserted at a given position landed one subview lower, beneath the sibling it should precede. The iOS View mapping now adds the effect view's slot while it is attached, and the layout mapping — which counts the native views of the preceding children for proxy containers and was overriding the platform base outright — hands its result to the base so both apply.
1 parent 4db0e64 commit ff2e222

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

packages/core/ui/core/view/index.ios.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,19 @@ export class View extends ViewCommon {
10031003
IOSHelper.invalidateStatusBarAppearance(ownerController, `View.updateStatusBarStyle:${value}`);
10041004
}
10051005

1006+
public _childIndexToNativeChildIndex(index?: number): number {
1007+
if (typeof index !== 'number') {
1008+
return index;
1009+
}
1010+
// The glass effect view is a subview but not a child: it sits at subview
1011+
// 0, so every child's subview index is one past its child index.
1012+
const effectView = this._glassEffectView;
1013+
if (effectView && effectView.superview === this.nativeViewProtected) {
1014+
return index + 1;
1015+
}
1016+
return index;
1017+
}
1018+
10061019
[iosGlassEffectProperty.setNative](value: GlassEffectType) {
10071020
if (!this.nativeViewProtected || !supportsGlass()) {
10081021
return;

packages/core/ui/layouts/layout-base-common.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,8 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
147147
result += this._subViews[i]._getNativeViewsCount();
148148
}
149149

150-
return result;
150+
// The platform base accounts for native subviews that are not children.
151+
return super._childIndexToNativeChildIndex(result);
151152
}
152153

153154
public eachChildView(callback: (child: View) => boolean): void {

0 commit comments

Comments
 (0)