fix(core): inheritable property changes backstack propagation (#10438)

[skip ci]
This commit is contained in:
Dimitris-Rafail Katsampas
2023-11-25 18:31:50 +02:00
committed by GitHub
parent 23127254ec
commit 48b1856d6c
4 changed files with 31 additions and 16 deletions

View File

@ -845,6 +845,12 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
//
}
public _inheritStyles(view: ViewBase): void {
propagateInheritableProperties(this, view);
view._inheritStyleScope(this._styleScope);
propagateInheritableCssProperties(this.style, view.style);
}
@profile
public _addView(view: ViewBase, atIndex?: number) {
if (Trace.isEnabled()) {
@ -874,9 +880,7 @@ export abstract class ViewBase extends Observable implements ViewBaseDefinition
* Method is intended to be overridden by inheritors and used as "protected"
*/
public _addViewCore(view: ViewBase, atIndex?: number) {
propagateInheritableProperties(this, view);
view._inheritStyleScope(this._styleScope);
propagateInheritableCssProperties(this.style, view.style);
this._inheritStyles(view);
if (this._context) {
view._setupUI(this._context, atIndex);

View File

@ -243,6 +243,7 @@ export class FrameBase extends CustomLayoutView {
public setCurrent(entry: BackstackEntry, navigationType: NavigationType): void {
const newPage = entry.resolvedPage;
// In case we navigated forward to a page that was in the backstack
// with clearHistory: true
if (!newPage.frame) {

View File

@ -916,6 +916,8 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
frame._resolvedPage = page;
if (page.parent === frame) {
frame._inheritStyles(page);
// If we are navigating to a page that was destroyed
// reinitialize its UI.
if (!page._context) {
@ -927,12 +929,16 @@ class FragmentCallbacksImplementation implements AndroidFragmentCallbacks {
page.callLoaded();
}
} else {
if (!page.parent) {
if (!frame._styleScope) {
// Make sure page will have styleScope even if parents don't.
page._updateStyleScope();
}
frame._addView(page);
} else {
throw new Error('Page is already shown on another frame.');
}
}
const savedState = entry.viewSavedState;

View File

@ -133,6 +133,9 @@ class UIViewControllerImpl extends UIViewController {
if (frame) {
frame._resolvedPage = owner;
if (owner.parent === frame) {
frame._inheritStyles(owner);
} else {
if (!owner.parent) {
if (!frame._styleScope) {
// Make sure page will have styleScope even if frame don't.
@ -140,9 +143,10 @@ class UIViewControllerImpl extends UIViewController {
}
frame._addView(owner);
} else if (owner.parent !== frame) {
} else {
throw new Error('Page is already shown on another frame.');
}
}
frame._updateActionBar(owner);
}