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

Issue of updating labels dynamically #117

Closed
TomislavMedved opened this issue Jan 4, 2022 · 11 comments
Closed

Issue of updating labels dynamically #117

TomislavMedved opened this issue Jan 4, 2022 · 11 comments
Labels
enhancement New feature or request help wanted Extra attention is needed no-issue-activity

Comments

@TomislavMedved
Copy link

TomislavMedved commented Jan 4, 2022

I have a classic situation where i have List of items on one route/page. When i click on a single item within a list, i am redirected to details page/route of that item. There i update label dynamically to show name of the item.

My issue is that each time you navigate from item list to item details you have 0.5 sec (some amount of time before you get data from backend) preview of the recent item name untill i set the new one. This happens every time except the first time (because we didnt dynamically update anything yet).
I update label dynamically by alias.

Is there any way to avoid showing recent label which was dynamically updated?

I have solved it by skipping that path also and then when upading via alias setting skip to false, but i feel that that is more like a hack then a proper solution.

@github-actions
Copy link

github-actions bot commented Jan 4, 2022

Hello 👋 @TomislavMedved
Thank you for raising an issue. We will investigate into the issue and get back to you as soon as possible. Please make sure you have given us as much context as possible.
Feel free to raise a PR if you can fix the issue. Check the local development guide

@udayvunnam
Copy link
Owner

Hey @TomislavMedved, this is a nice feature to have to improve the UX of the app.

This is achievable. I will work on the API to achieve such behaviour.

what would you expect in case item details service fails to provide a label on error.

@udayvunnam
Copy link
Owner

udayvunnam commented Jan 5, 2022

@TomislavMedved you can do this with existing breadcrumb APIs

// skip item details breadcrumb in routing module declaration
  {
    path: 'itemDetailsPath',
    component: ItemDetailsComponent,
    data: { breadcrumb: { skip: true, alias: 'itemDeatils' } }
  }
  
  // set breadcrumbs just after getting data from the component
  
   this.breadcrumbService.set('@itemDeatils', {skip: true});
   this.itemService.getItemDetails(itemId).subscribe((response) => {
      this.item = response;
      this.breadcrumbService.set('@itemDeatils', {label: this.item.name, skip: false});
   });

@TomislavMedved
Copy link
Author

TomislavMedved commented Jan 11, 2022

Yeah, but there's another issue with that approach, if you have a parent route which contains multiple children routes, and i update parent route with lets say List Name via alias and skip false, it will be shown initially on the first child route, but if i switch to another child route, list name that was updated dynamically is hidden again, it didn't remember newly skip false value but took initial skip true from the initial config from route.ts

Example:
{ path: ':cid/show', component: BoxDetailsComponent, data: { breadcrumb: { skip: true, alias: 'boxName' } }, children: [ { path: 'items', component: BoxItemsComponent, }, { path: 'dimensions', component: BoxDimensionsComponent }, { path: 'properties', component: BoxPropertiesComponent }, }

Here in the example where we are directed to :cid/show/items initially. Parent :cid/show has breacrumbs skip true with boxName alias. Skip is true so we avoid issue of seeing old boxName for a breif second untill we get data for new box from the BE.
When data is fetched from BE i update breadcrumbs with
this.breadcrumbService.set('@boxName', { label: boxBackend.name, skip: false });
Box name is shown, but when we go to :cid/show/dimensions box name is lost from breadcrumbs. I guess API doesnt hold the newly updated values over breadcrumbs service. It would be good if there could be a setting weather to remember new updated states.

If we dont use skip and use it normaly, it works, but then we have an issue of seeing old boxName for a time while new one is fetched.
It would work if i update each children route specificly and not the parent, and update dynamically from each children's route boxName, but thats not good, its repetative and duplicated code.

@udayvunnam udayvunnam assigned udayvunnam and unassigned udayvunnam Feb 1, 2022
@udayvunnam udayvunnam added enhancement New feature or request help wanted Extra attention is needed labels Feb 1, 2022
@stale
Copy link

stale bot commented Jun 10, 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. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Jun 10, 2022
@udayvunnam udayvunnam removed the wontfix This will not be worked on label Aug 3, 2022
@udayvunnam
Copy link
Owner

not stale

@stale
Copy link

stale bot commented Dec 3, 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. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 3, 2022
@stale stale bot closed this as completed Apr 7, 2023
@udayvunnam udayvunnam reopened this May 27, 2023
@stale stale bot removed the wontfix This will not be worked on label May 27, 2023
@stale
Copy link

stale bot commented Oct 15, 2023

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

@stale stale bot added the wontfix This will not be worked on label Oct 15, 2023
@stale stale bot closed this as completed Mar 17, 2024
@udayvunnam udayvunnam removed the wontfix This will not be worked on label Mar 17, 2024
@udayvunnam udayvunnam reopened this Mar 17, 2024
@jamesrusso
Copy link

I am trying to find a solution for the same issue. On the initial page load is has the of the object for me and then I set the alias and it'll flicker. I'd rather the entire item not show up until the aliases are set

@jamesrusso
Copy link

My solution was to simply not show the breadcrumbs during navigation. In the component containing the breadcrumbs I simply added the following:

 <xng-breadcrumb [separator]="separator" *ngIf="breadcrumbVisible$ | async">
        <ng-container *xngBreadcrumbItem="let breadcrumb; let info = info; let first = first; let last = last">
          <ng-container>{{ breadcrumb }}</ng-container>
        </ng-container>
      </xng-breadcrumb>      
    this.router.events.pipe(filter((event) => event instanceof NavigationStart || event instanceof NavigationEnd)).subscribe((event) => {
      this.breadcrumbVisible$.emit(event instanceof NavigationStart ? false : true);
    })

So, now the breadcrumbs won't be displayed until after the navigation has ended and it seems to no longer display the wrong name briefly.

Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed no-issue-activity
Projects
None yet
Development

No branches or pull requests

3 participants