Skip to content

Detect navigation change in SPFX Application customizer #1254

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

Closed
1 of 4 tasks
pmatthews05 opened this issue Jan 19, 2018 · 8 comments
Closed
1 of 4 tasks

Detect navigation change in SPFX Application customizer #1254

pmatthews05 opened this issue Jan 19, 2018 · 8 comments
Labels
area:spfx Category: SharePoint Framework (not extensions related) status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.

Comments

@pmatthews05
Copy link

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

Expected or Desired Behavior

I have a SPFX customizer that displays a banner in the topPlaceholder. When the page loads, if it's a list, then it performs a calculation and then displays the banner.

When I move from one library to another, because the page isn't performing a full load, I found out I need use the navigatedEvent. This fires when the navigation changes.

However, I need to display the banner differently depending on what folder I'm in within a single document library. When navigating from one folder to another in a document library the navigatedEvent doesn't seem to fire, even though I am navigating to a different location.

Is this a bug with the navigatedEvent, or should I be using a different event?

Observed Behavior

When navigating from one folder to another, the navigatedEvent doesn't fire.

Steps to Reproduce

Have the following code running on a document libraries. Have a document library with folders. View the debug console of the browser. If you navigate between the folders, you will discover that the renderControl doesn't fire again. It only fires on changes between libraries (if deployed to app catalog, not running through debug localhost session)

` public onInit(): Promise {
this.context.application.navigatedEvent.add(this, this.renderControl);
return Promise.resolve();
}

private renderControl(){

console.log("Rendering control');
Log.info(LOG_SOURCE, Available placeholders: ${this.context.placeholderProvider.placeholderNames.map(name => PlaceholderName[name]).join(', ')});

//handling the top placeholder
if(!this._topPlaceholder){
  this._topPlaceholder = this.context.placeholderProvider.tryCreateContent(
      PlaceholderName.Top, 
      {onDispose: this._onDispose});

  if(!this._topPlaceholder){
    console.error(`The expected placholder (Top) was not found.`);
    return;
  }  
}

if(this._topPlaceholder.domElement){
    const element : React.ReactElement<IInfoBarMainProps> = React.createElement(
      MainBar,{
            context: this.context
      }
    );
    ReactDom.render(element, this._topPlaceholder.domElement);
}

}

private _onDispose(){
Log.info(LOG_SOURCE, [IInfoBarApplicationCustomizer._onDispose] Disposed custom top placeholders);
}`

Is there a different event I should be using? Also, if I navigated inside a folder, is there a way to work out which folder with a URL?

@VesaJuvonen VesaJuvonen added the status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) label Jan 23, 2018
@VesaJuvonen
Copy link
Contributor

Potential duplicate as #1265.

@VesaJuvonen VesaJuvonen added type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. area:spfx Category: SharePoint Framework (not extensions related) labels Jan 25, 2018
@pmatthews05
Copy link
Author

@VesaJuvonen although my issue similar to #1265, it not quite the same. My issue is that navigatedevent doesn't fire when you navigate inside folders that are in the document library. The other issue seems to be about the placeholders not available when switching pages.

@VesaJuvonen
Copy link
Contributor

yes - we do get that, but root cause or the issue is similar to the internal event handling in the Framework, which is why we cross-linked this in GitHub and in VSO. Obviously, we'll need to ensure that we have all of these fixed properly asap and the issue is being looked at by our engineering.

@ahackettms
Copy link

@pmatthews05 we are working on providing a solution to provide folder information in page context when navigate into a folder, and fire the navigation event.

@OmniFace
Copy link

OmniFace commented Apr 4, 2018

The navigatedEvent also do not fire if performing a search or returning to the home page, unless you started on the search page (refresh or bookmark) and then move to the home page.

Is this a bug as well? Is navigatedEvent supposed to fire with all page transitions that don't reload the DOM?

@VesaJuvonen
Copy link
Contributor

We have now changed our eventing model related on fix with #1042. This should be solving this issue as well, so closing this. If you still have issues around this, please do let us know. Thx.

@dhruvp29
Copy link

I am still facing this issue. When navigating from one folder to another, the navigatedEvent doesn't fire.

@msft-github-bot
Copy link
Collaborator

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

@SharePoint SharePoint locked as resolved and limited conversation to collaborators Jan 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:spfx Category: SharePoint Framework (not extensions related) status:tracked Currently tracked with Microsoft’s internal issue tracking system. DO NOT ADD/REMOVE (MSFT managed) type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Projects
None yet
Development

No branches or pull requests

6 participants