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

SPFx Field Customizer - onInit executes multiple times when navigating between folders in same document library #8552

Closed
2 of 9 tasks
SaadKnowIT opened this issue Nov 3, 2022 · 9 comments
Labels
area:spfx Category: SharePoint Framework (not extensions related) status:fixed-next-drop Issue planned to be fixed in an upcoming release. type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs.
Milestone

Comments

@SaadKnowIT
Copy link

Target SharePoint environment

SharePoint Online

What SharePoint development model, framework, SDK or API is this about?

💥 SharePoint Framework

Developer environment

No response

What browser(s) / client(s) have you tested

  • 💥 Internet Explorer
  • 💥 Microsoft Edge
  • 💥 Google Chrome
  • 💥 FireFox
  • 💥 Safari
  • mobile (iOS/iPadOS)
  • mobile (Android)
  • not applicable
  • other (enter in the "Additional environment details" area below)

Additional environment details

Versions:

  • Microsoft Edge version: Version 107.0.1418.26 (Official build) (64-bit)
  • Chrome version: Version 106.0.5249.119 (Official Build) (64-bit)
  • SPFx version: 1.15.2
  • Node.js version: 16.13.0 (64-bit)

Describe the bug / error

I am developing an SPFx Extension Field Customizer that is supposed to run in an document library with many levels of folders and documents.

The problem i am having is that the "onInit" function is executed multiple times when navigating between the folders in the document library. I am executing an request to SharePoint through the PnPJs library from inside the onInit function.

On initial visit to the document library, this is the order of how the default function execute:
image

If i decide to navigate in to one of these folders from this view, then this is the execution order of the default functions:
image

If i navigate back up to the root folder and then to a different folder (still one level down). Then this is the execution order of the default functions:
image

If i right click on a document or a folder in the same view as above to open the object menu, it triggers the default functions again:
image

This behavior i explained above continues as i navigate to a new folder in the same document library. For every new folder i navigate to, the execution count for the onInit executions increase by one.

Steps to reproduce

  1. Create a new SPFx Extension - Field Customizer with React as a template using yo.

  2. Add these for the console log outputs as show in my pictures above.
    image

  3. Add the column associated with your Field Customizer to a document library.

  4. run gulp serve and test it against the document library.

Expected behavior

I expect the oninit function to be executed only once for each navigation event made between the folders.

@SaadKnowIT SaadKnowIT added the type:bug-suspected Suspected bug (not working as designed/expected). See “type:bug-confirmed” for confirmed bugs. label Nov 3, 2022
@ghost
Copy link

ghost commented Nov 3, 2022

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@ghost ghost added the Needs: Triage 🔍 Awaiting categorization and initial review. label Nov 3, 2022
@AJIXuMuK AJIXuMuK added area:spfx Category: SharePoint Framework (not extensions related) and removed Needs: Triage 🔍 Awaiting categorization and initial review. labels Nov 3, 2022
@SaadKnowIT
Copy link
Author

@AJIXuMuK, any idéa why this is happening? Is this expected behavior? Any workaround?

@SaadKnowIT
Copy link
Author

@andrewconnell & @VesaJuvonen, do you guys have any insight into this?

@AJIXuMuK
Copy link
Collaborator

AJIXuMuK commented Jan 5, 2023

@SaadKnowIT - sorry for the silence.
I'm able to repro it and will be working on the fix.

@AJIXuMuK AJIXuMuK added the status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. label Jan 5, 2023
@SaadKnowIT
Copy link
Author

@AJIXuMuK - Glad to here that you are working on this. Waiting for your findings/results.

@AJIXuMuK AJIXuMuK added status:fixed-next-drop Issue planned to be fixed in an upcoming release. and removed status:working-on-it Known issue / feature being addressed. Will use other "status:*" labels & comments for more detail. labels Jan 11, 2023
@AJIXuMuK AJIXuMuK added this to the 01-13-23 milestone Jan 11, 2023
@AJIXuMuK
Copy link
Collaborator

@SaadKnowIT - the issue has been fixed and will be included in the next release.
To set the expectations: onInit will be called once per customizer/list.
It means that it may not be called if you navigate between 2 lists because the state of the list is cached and the customizer has been already initialized. Don't use this handler to handle navigation of any type.

@SaadKnowIT
Copy link
Author

@AJIXuMuK, thanks for the reply and the fix. Will test it when it is released.

What am i supposed to use to handle navigation events (Navigating between folders) inside the same library/list or when navigating between different libraries/lists.

@AJIXuMuK
Copy link
Collaborator

AJIXuMuK commented Mar 1, 2023

this should be rolled out worldwide by now

@AJIXuMuK AJIXuMuK closed this as completed Mar 1, 2023
@ghost
Copy link

ghost commented Mar 8, 2023

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

@ghost ghost locked as resolved and limited conversation to collaborators Mar 8, 2023
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:fixed-next-drop Issue planned to be fixed in an upcoming release. 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

2 participants