Content-Length: 371565 | pFad | http://github.com/NativeScript/NativeScript/pull/10690/files

A3 fix(core): ignore inserting child if < 0 by NathanWalker · Pull Request #10690 · NativeScript/NativeScript · GitHub
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(core): ignore inserting child if < 0 #10690

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 7 additions & 7 deletions packages/core/ui/layouts/layout-base-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi
this._registerLayoutChild(child);
}

public insertChild(child: View, atIndex: number): void {
if (atIndex < 0) {
throw new Error('Cannot insert a child to a negative index.');
public insertChild(child: View, atIndex: number): boolean {
if (atIndex > -1) {
this._subViews.splice(atIndex, 0, child);
this._addView(child, atIndex);
this._registerLayoutChild(child);
return true;
}

this._subViews.splice(atIndex, 0, child);
this._addView(child, atIndex);
this._registerLayoutChild(child);
return false;
}

public removeChild(child: View): void {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/ui/layouts/layout-base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class LayoutBase extends CustomLayoutView {
* @param view The view to be added to the end of the children array.
* @param atIndex The insertion index.
*/
insertChild(child: View, atIndex: number): void;
insertChild(child: View, atIndex: number): boolean;

/**
* Removes the specified view from the children array.
Expand Down
9 changes: 6 additions & 3 deletions packages/core/ui/layouts/layout-base.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ export class LayoutBase extends LayoutBaseCommon {
this.requestLayout();
}

public insertChild(child: View, atIndex: number): void {
super.insertChild(child, atIndex);
this.requestLayout();
public insertChild(child: View, atIndex: number): boolean {
if (super.insertChild(child, atIndex)) {
this.requestLayout();
return true;
}
return false;
}

public removeChild(child: View): void {
Expand Down
27 changes: 15 additions & 12 deletions packages/core/ui/layouts/root-layout/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ import { LinearGradient } from '../../styling/linear-gradient';
export * from './root-layout-common';

export class RootLayout extends RootLayoutBase {
insertChild(view: View, atIndex: number): void {
super.insertChild(view, atIndex);
if (!view.hasGestureObservers()) {
// block tap events from going through to layers behind the view
if (view.nativeViewProtected) {
view.nativeViewProtected.setOnTouchListener(
new android.view.View.OnTouchListener({
onTouch: function (view, event) {
return true;
},
}),
);
insertChild(view: View, atIndex: number): boolean {
if (super.insertChild(view, atIndex)) {
if (!view.hasGestureObservers()) {
// block tap events from going through to layers behind the view
if (view.nativeViewProtected) {
view.nativeViewProtected.setOnTouchListener(
new android.view.View.OnTouchListener({
onTouch: function (view, event) {
return true;
},
}),
);
}
}
return true;
}
return false;
}
removeChild(view: View): void {
if (view.hasGestureObservers() && view.nativeViewProtected) {
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/NativeScript/pull/10690/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy