angular-ui / ui-router

The de-facto solution to flexible routing with nested views in AngularJS
http://ui-router.github.io/
MIT License
13.54k stars 3k forks source link

Sibling states getting mixed up in new/update scenario #3523

Closed dietergeerts closed 4 years ago

dietergeerts commented 7 years ago

This is a:

My version of UI-Router is: 1.0.3

Bug Report

Current Behavior:

I have two states:

createState = {url: '/new'};
updateState = {url: '/:id'};

Now when loading the page with url mysite.com/users/new, it loads the updateState instead of the createState. A current workaround is to add the createState after the updateState on the $stateProvider, but that's harder to control as we use encapsulating modules for each thing to better control our dependencies, so a state file is like:

import angular from 'angular';
import uiRouterModule from '@uirouter/angularjs';
import {appLoginComponentModule} from '../login.component';
import {notAuthState} from '../../app.states';
import {loginResolve} from '../core/action/login.resolve';
import {appAuthModule} from '../../auth/core/auth';

export const loginState = {
    name: 'user_login',
    parent: notAuthState,
    url: '/login',
    component: 'appLogin',
    resolve: {
        login: loginResolve,
    },
};

export const appLoginStateModule = angular
    .module('app.login.state', [
        uiRouterModule,
        appAuthModule,
        appLoginComponentModule,
    ])
    .config(/* @ngInject */ ($stateProvider) => {
        $stateProvider.state(loginState);
    })
    .name;

And then we can add that dependency to the modules that needs it, and we can't be sure that the createState is added after the updateState with this.

Expected Behavior:

I would expect the ui-router to check of there is a sibiling state that hasn't a paramter, and check if that's a match first, so that order isn't important.

Link to Plunker that reproduces the issue:

If really needed, I can add one, just let me know.

i23591326 commented 7 years ago

I have a related issue:

In my case there are two states: {name: '...dashboard.widget', url: '/widget:dashboard',...}; {name: '...dashboard.widgetconfig', url: '/widgetconfig:dashboard',...};

It works perfectly fine when i use ui-sref directive for state transition. However when current state is ....widgetconfig and url is .../widgetconfig123, in case if i update browser page, uirouter will set ...widget state with url .../widgetconfig123!!! after app is loaded

uirouter/angularjs: 1.0.6, uirouter/core: 5.0.6

toxaq commented 7 years ago

See also #1277 Utterly silent failings after an upgrade are very embarassing...

toxaq commented 6 years ago

Also seems to be intermittent. I've been able to run through this locally fine, deploy and then find that some routes are borked for some users and not necessarily reproducible...

kfroemming-cb commented 6 years ago

I am having this issue as well. Has there been any progress?

josduj commented 6 years ago

Updating to 1.0.15 fixed my issues

dietergeerts commented 6 years ago

@josduj , problem is reported on 1.0.3. So that could mean that it was introduced after 1.0.15 or that your scenario is different

toxaq commented 6 years ago

@dietergeerts 1.0.15 is after 1.0.3 so I think @josduj is implying it might have been fixed? The problem is testing it. It was intermittent for me and seemed to be based on load orders (possibly with lazy loading at my end) so there was not replicatable test. I've upgraded to 1.0.15 but didn't remove the regexp fix as per https://github.com/angular-ui/ui-router/issues/1277#issuecomment-224519357.

dietergeerts commented 6 years ago

Oops. I saw 30 in my head. I'll try to upgrade and see if it's fixed.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

This does not mean that the issue is invalid. Valid issues may be reopened.

Thank you for your contributions.