Skip to content
This repository has been archived by the owner on Sep 20, 2020. It is now read-only.

sticky child state gets lost when returning to its parent from other than the child #212

Closed
molog opened this issue Jun 26, 2015 · 6 comments

Comments

@molog
Copy link

molog commented Jun 26, 2015

The situation is like this:

I have 3 states(all sticky):
parent1
parent1.child1
parent2

steps:
-> child1 -> parent2 -> parent1 , this causes child1 to disappear and re-access child1 will cause re-initialising the scope, which is not wanted

plunkr:
http://plnkr.co/edit/tnjbOn97BHCkNy3DLa4M?p=preview

Is it a bug? Is there any way to remember child1 once it is accessed? Thx

@christopherthielen
Copy link
Owner

Did you try deep state redirect?

@molog
Copy link
Author

molog commented Jun 27, 2015

Putting a deepStateRedirect on parent1
This worked that child1 is no longer lost. But this will make parent1 always redirect to child1 if child1 has been accessed. How could I go to parent1 only?

from the debug info, the inactive states list shows:

  1. when I left child1 to parent2, inactive states: ["top.parent1.child1", "top.parent1"]
    Both parent1 and child1 were remembered. This is expected

  2. when I entered to parent1, inactive states: ["top.parent2"]
    "top.parent1.child1" went lost. Is this expected?

It seems the problem is when entering parent state from a state other than its child states, it forgets its sticky child states

@Astray-git
Copy link

hmm I have similar problem after upgrade to 0.0.14
I have a multi column with 2 sticky states on left/right side,
initial layout is: left1 | empty
steps:
parent.left1 -> parent.left2 -> parent.left1 -> parent.right1
then parent.left1 disappears, parent.left2 shows up, layout becomes left2 | right 1
the expected result is left1 | right1

@cheahkhing
Copy link

I am having similar problem only when i enable futureState together with stickyState.
You might want to turn the debug mode on, and look at how the transitions going on.

@christopherthielen
Copy link
Owner

This is confirmed as a bug.

Given a sticky state with a sticky substate

      A (sticky)    B
    A.1 (sticky)

There is a difference in how a sticky substate (A.1) is handled when:

  • Navigating to A will reactivate A (B -> A)
    • A.1 is exited
  • Navigating to A when A is already entered (A.1 to A)
    • A.1 remains inactive

The docs say that the sticky state DOM/controller is retained until the parent to the sticky state is exited. This statement is not precisely followed, as the two bullet points above demonstrate. I am going to change the expected behavior to the following statement:

BC-BREAK

  • A sticky state's DOM/controller is retained until the parent state is either: exited, or directly activated

another way to phrase that is:

  • A sticky state's DOM/controller is retained while either: the parent is inactive or a sibling of the sticky is active

This is a BC-BREAK from 0.0.14, but it is more internally consistent and consistent with the intention of sticky states.


OP, if you want control over how parent1 and parent1.child1 interact, I suggest using:

  • dsr: true to get parent1 to redirect to parent1.child
  • $state.go(parent1, null, {ignoreDsr: true}) to navigate directly to parent1

@christopherthielen
Copy link
Owner

updated plunk with ui-router-extras 0.0.15-pre3

http://plnkr.co/edit/sQIGly0ImyZYtdus4iuy?p=preview

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants