Skip to content

Allow tab reload when the 1st load failed - #2325

Open
officialasishkumar wants to merge 1 commit into
atk4:developfrom
officialasishkumar:tab_reload_after_failed_load
Open

officialasishkumar wants to merge 1 commit into
atk4:developfrom
officialasishkumar:tab_reload_after_failed_load

Conversation

@officialasishkumar

Copy link
Copy Markdown

fix #2256

Fomantic-UI calls the onFirstLoad tab callback only once, even when the request it started failed, so a tab whose 1st load failed stayed blank until the whole page was reloaded.

As suggested in the issue, the tab now uses onLoad, which is called on each activation, and tracks the loaded state itself:

  • The state is stored using jQuery data of the tab subview, because the virtual page element is replaced by the loaded content.
  • The state is set before the request is sent, so activating the tab during a pending load does not send a 2nd request.
  • The state is removed in onComplete when the request did not succeed. onSuccess and onFailure are not used because they would replace the global handlers from apiService.

Tabs with cache => false are unchanged and successfully loaded tabs remain cached.

Added a tab.feature scenario, which fails without the fix. I also checked these flows in Chromium using a temporary page with server-side request counters: a load that fails once and then succeeds, a cached tab that sends only one request, and activating a tab during a pending load.

Behaviour note for cached tabs with a callback: onLoad passed in $settings and apiSettings.onComplete are now overwritten by this logic. onLoad was already overwritten for cache => false tabs, and nothing in the repository passes either of them.

Fomantic-UI calls the "onFirstLoad" tab callback only once, even when the
request it started failed. A tab whose 1st load failed, for example because
of a server exception or a network error, stayed blank until the whole page
was reloaded.

Use the "onLoad" callback, which is called each time a tab is activated, and
track the loaded state using jQuery data of the tab subview, as the virtual
page element is replaced by the loaded content. The state is set before the
request is sent, so activating the tab during a pending load does not send
a 2nd request, and it is removed when the request did not succeed.

Successfully loaded tabs remain cached, no additional request is sent when
they are activated again.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Allow tab reload when the 1st load failed

1 participant