GithubHelp home page GithubHelp logo

Comments (15)

mgerstenblatt avatar mgerstenblatt commented on April 19, 2024 2

I ran into the same problem as @kuhnroyal -- dynamic parameters don't work at all in any state after applying the plugin.

I'm using Angular 1.x and followed the instructions in #4 to include sticky states.

from sticky-states.

kuhnroyal avatar kuhnroyal commented on April 19, 2024

I just ran into the problem that dynamic parameters do not work at all after I apply the plugin, even without using any sticky state.

from sticky-states.

mgerstenblatt avatar mgerstenblatt commented on April 19, 2024

I've opened a PR in ui-router core that I think addresses this issue: ui-router/core#72

from sticky-states.

christopherthielen avatar christopherthielen commented on April 19, 2024

@mgerstenblatt I really appreciate the analysis and the PR! I'm a bit afraid of side effects of changing the semantics for "stock ui-router" treeChanges. It seems like sticky states itself could handle this by returning:

tc.reactivating = simulatedTC.to.slice(tc.retained.length);

do you want to try and let me know?

from sticky-states.

mgerstenblatt avatar mgerstenblatt commented on April 19, 2024

@christopherthielen, I don't think that approach works because when you reload a state (after updating the parameters for example) simulatedTC.to and tc.retained are the same length and you end up with an empty array.

I understand your concerns about modifying the ui-router core and would love a solution that didn't have to modify it. However, from scanning the usage of the treeChanges, I believe my changes have minimal impact.

from sticky-states.

mgerstenblatt avatar mgerstenblatt commented on April 19, 2024

@christopherthielen, what about doing something similar where we apply the to params like in https://github.com/ui-router/core/blob/master/src/path/pathFactory.ts#L121

from sticky-states.

mgerstenblatt avatar mgerstenblatt commented on April 19, 2024

@christopherthielen, something like https://github.com/ui-router/sticky-states/pull/15/files

from sticky-states.

Aidamir avatar Aidamir commented on April 19, 2024

I have faced with the issue while reactivating the sticky state with the updated dynamic parameter. (It did not update parameter at all). I did apply @mgerstenblatt patch #15 , but it still didn't work. Then I found there is missing params update for reactivating nodes in patch. I have added one line to the code and it did start to work. my updated code looks:


      // Rewrite the to path
      let retainedWithToParams = tc.retained.map((retainedNode,idx) => applyToParams(retainedNode,tc.to,idx));
      let reactivatingWithToParams = tc.reactivating.map((retainedNode,idx) => applyToParams(retainedNode,tc.to,(idx + tc.retained.length)));
      tc.to = retainedWithToParams.concat(reactivatingWithToParams).concat(tc.entering);
    }

@christopherthielen, Please explain why don't you accept #15 ?
here is updated js, ts may will be useful for test src.tar.gz

from sticky-states.

jnfeinstein avatar jnfeinstein commented on April 19, 2024

I'm not seeing this issue specifically but am seeing lots of issues with query parameters.

@christopherthielen is there an ETA for fixes (this and #16, maybe related)? Would love to use this library. Unfortunately I don't have bandwidth to fix myself.

from sticky-states.

jnfeinstein avatar jnfeinstein commented on April 19, 2024

Confirmed, this is the same issue I'm experiencing. #10 is also the same issue.

from sticky-states.

nkoterba avatar nkoterba commented on April 19, 2024

Have to agree with @vladtar here...

It looks like the PathFactory really should be returning retainedWithParams instead of retained. It almost looks like the wrong variable was returned

or

retainedWithParams should be included in the treeChanges object and then the stickyStates plugin can just utilize that instead of the original retained object.

from sticky-states.

nerdo avatar nerdo commented on April 19, 2024

I believe this is the issue I ran into as well and didn't fully understand what was going on as I am new to sticky states. To be honest, I still don't fully understand why it happens, but I'll explain my scenario just in case it is slightly different.

Like the OP, I have two states set up in a similar fashion with few exceptions. First, my sticky state had parameters that were not declared dynamic. Secondly, my sticky state had no url, and I was not trying to change any parameters; I was trying to return to stateB with it's original parameters (essentially a "go back" function).

Instead of everything in stateB showing up untouched, I found, through console logging, that the component that stateB was routed to was being re-initialized and it did seem like the parameters were not being passed through.

So there may be two issues here. The one that has been mentioned where the parameter is not changing, but it also seems like the sticky state is not recognizing that the state is already alive. If it did, I shouldn't be seeing the component get re-initialized.

I ended up writing a hacky workaround using a constant object to pass params and then injected that into the constant as a dependency.

For the small-scale project I ran into this on, this will do, but this is a pretty big deal breaker for use in larger scale projects.

from sticky-states.

christopherthielen avatar christopherthielen commented on April 19, 2024

Looks like the change I made in @uirouter/core for this broke a lot of other things. Stay tuned.

from sticky-states.

mgerstenblatt avatar mgerstenblatt commented on April 19, 2024

@christopherthielen, for what it's worth, I've been using a patched version of sticky-states (https://github.com/ui-router/sticky-states/pull/15/files) instead of the change to ui-router/core in production since the summer and haven't had any issues.

from sticky-states.

christopherthielen avatar christopherthielen commented on April 19, 2024

Fixed by 3696bf9

from sticky-states.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.