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

child states of lazy loaded future states get stuck in stateQueue #3836

Open
1 of 3 tasks
alexgoff opened this issue Aug 26, 2021 · 1 comment
Open
1 of 3 tasks

child states of lazy loaded future states get stuck in stateQueue #3836

alexgoff opened this issue Aug 26, 2021 · 1 comment
Labels

Comments

@alexgoff
Copy link

alexgoff commented Aug 26, 2021

This issue tracker is for Bug Reports and Feature Requests only.

Please direct requests for help to StackOverflow.
See http://bit.ly/UIR-SOF for details.

This is a (check one box):

  • Bug Report
  • Feature Request
  • General Query

My version of UI-Router is: 1.0.29

Bug Report

Current Behavior:

  • Define a main application state
  • Define a future state to lazy load a module using the glob double wildcard
export const clientAdminLandingFutureState: Ng1StateDeclaration = {
    name: 'clientAdmin.**',
    parent: 'app',
    url: '/admin',
        lazyLoad: function(transition: Transition) {
        const $ocLazyLoad: ILazyLoad = transition.injector().get('$ocLazyLoad');
        const $log: ILogService = transition.injector().get('$log');

        return import(
            /* webpackChunkName: "clientAdminLanding" */ './client-admin-landing.module'
        )
            .then(({ ClientAdminLandingModule }) =>
                $ocLazyLoad.load(<any>ClientAdminLandingModule)
            )
            .catch((err) => $log.error(err));
    }
};
  • Define another future state to lazy load a module that is a child of the first state
export const proxyFutureState: Ng1StateDeclaration = {
    name: 'proxy.**',
    parent: 'clientAdmin',
    url: '/proxy',
    lazyLoad: (transition: Transition) => {
        const $ocLazyLoad: ILazyLoad = transition.injector().get('$ocLazyLoad');
        const $log: ILogService = transition.injector().get('$log');

        return import(/* webpackChunkName: "proxy" */ './proxy.module')
            .then(({ ProxyModule }) => $ocLazyLoad.load(<any>ProxyModule))
            .catch((err) => $log.error(err));
    }
};
  • Register each future state with the $stateRegistry
import { module } from "angular";

import { clientAdminLandingFutureState } from "./src/client-admin-landing/client-admin-landing.future-state";
import { proxyFutureState } from "./src/proxy/proxy-future-state";

const AppModule = module("appModule", []).config(
  /* @ngInject */($stateRegistry, $stateProvider) => {
        $stateProvider.state('app', {
            abstract: true,
            views: {
                master: {
                    templateUrl: '/templates/core/master-layout.html',
                    controller: 'coreController'
                },
            }
        });
        
        $stateRegistry.register(clientAdminLandingFutureState);
        $stateRegistry.register(proxyFutureState);
  }
);
  • When logging $stateRegistry.stateQueue.queue through the onStatesChanged listener or through an $onInit the child future state is still queued:
    [self: {name: "proxy.**", parent: "clientAdmin", url: "/proxy", lazyLoad: ƒ, $$state: ƒ}]

Expected Behavior:

If the parent state is already defined, the child state should be registered and not queued. If the child state is put into the queue, it should be registered after the parent state is registered.

My thinking is that the double wildcard is preventing the child and parent names from matching

Link to Plunker or stackblitz that reproduces the issue:

See code sample above

@stale
Copy link

stale bot commented Apr 18, 2022

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.

@stale stale bot added the stale label Apr 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant