question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

setNavigation() is invoked before all pages are loaded

See original GitHub issue

When loading several pages, I have noticed that my navigation bar (.cms_nav) was lacking some links. My guess, the reason for that is that the end of content load is compared with page count using an ID-like-variable, not an actual counter.

Short explanation

Pages are loaded asynchronously and the “counter” (value that is accessed by Ajax success) is passed by iterating the filenames in getFiles(). The navigation bar is loaded when the counter is equal to the count of the pages. There can be a situation where a last page is loaded first and the navigation bar is created prematurely.

Long explanation

Load flow goes like this:

  • CMS.getFiles(type) is invoked at line 428 where type === 'page'
  • Inside getFiles(type) Ajax call is performed to get files in the directory
  • On success .md filenames are extracted
  • For each file CMS.getContent() is invoked at line 350 with iterated “counter”
  • Each file is fetched in CMS.getContent() using an Ajax call
  • On success ‘parseContent()’ is invoked passing a “counter”
  • If counter === numFiles (i.e., if the “counter” of the file is the same as the count of files), the CMS.contentLoaded() is invoked (at line 245) and (if posts are loaded already), navigation bar is loaded

This means, that if the last page (alphanumerically on the getFiles() Ajax load) is loaded first, then counter === numFiles is true, and the navigation is not loaded properly.

Replication

Create pages A.mb, B.mb and C.mb. Make A substantially larger so it would load last. Navigation bar should only contain C (and maybe B) and not A. Make sure to clean the cache.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisdianacommented, Mar 27, 2017

Hey guys! I’m back and trying to get this train rolling again. Over the next few weeks I’m going to try and get caught up with these issues and PRs. Thanks for all the suggestions and support!

0reactions
rimseliscommented, Sep 6, 2016

@codeGlaze, yeah, was wondering if that will happen. Maybe with #71 things will start moving forward.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NET MAUI Shell navigation - Microsoft Learn
Register detail page routes. In the Shell subclass constructor, or any other location that runs before a route is invoked, additional routes ...
Read more >
execute function after complete page load - javascript
$(document).ready() fires on DOMContentLoaded, but this event is not being ... event is a step backwards since the DOM will load before all...
Read more >
Page: DOMContentLoaded, load, beforeunload, unload
load – not only HTML is loaded, but also all the external resources: images, styles etc. beforeunload/unload – the user is leaving the...
Read more >
Add Active Navigation Class Based on URL - CSS-Tricks
Works like a charm with one exception. One the home page the class is added to all the links. The all start with...
Read more >
Get started with the Navigation component - Android Developers
On this page; Set up your environment; Create a navigation graph; Navigation Editor; Add a NavHost to an activity.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found