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

Command Set onInit is executed only once #6116

Closed
2 tasks done
waaromikniet opened this issue Jul 29, 2020 · 6 comments
Closed
2 tasks done

Command Set onInit is executed only once #6116

waaromikniet opened this issue Jul 29, 2020 · 6 comments
Labels
area:spfx-extensions Category: SharePoint Framework Extensions Needs: Attention 👋 Original poster responded to request for feedback, awaiting attention from Microsoft / community. type:question Question... if answered, will be tagged as such.

Comments

@waaromikniet
Copy link

waaromikniet commented Jul 29, 2020

Category

  • Bug?
  • Question

Describe the bug

The oninit() for my command set is only executed once. This happens after navigating to another list and go back to my original list.

Is this behavior by design? Or is this a bug that I found. I only wan't to enable my custom command set on specific list so I use the oninit() at this moment to do this. But this breaks when switching lists through navigating in the quick launch. When doing a hard refresh with CTRL+F5 the oninit() is fired again.

Steps to reproduce

Create 2 custom lists
Add both to quick launch
Create a Hello World Command Set example with console.log() in the oninit()
Deploy the solution
Click on list 1 in the quick launch and see a console log
Click on list 2 in the quick launch and see a console log
Now click again on list 1 in the quick launch. There is no oninit in the console.log.
When setting a breakpoint in the oninit() see it isn't called

Expected behavior

When I click on list 1 in the quick launch I see a console log
When I click on list 2 in the quick launch I see a console log
When I now click again on list 1 in the quick launch I want to see a console log oninit()
I use the oninit() to enable of disable the command on specific list with specific contentypes.
So I want to use the oninit() to do this.

Environment details (development & target environment)

Windows 10
SharePoint online
Node V10
Browser: Chrome
VSCode, SpFx 1.10

image

@msft-github-bot
Copy link
Collaborator

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

@msft-github-bot msft-github-bot added the Needs: Triage 🔍 Awaiting categorization and initial review. label Jul 29, 2020
@andrewconnell andrewconnell added area:spfx-extensions Category: SharePoint Framework Extensions type:question Question... if answered, will be tagged as such. and removed Needs: Triage 🔍 Awaiting categorization and initial review. labels Jul 31, 2020
@andrewconnell
Copy link
Collaborator

A fix has been applied to a similar issue... see #6611... can you verify if this resolved your issue?

@andrewconnell andrewconnell added the Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. label Mar 4, 2021
@waaromikniet
Copy link
Author

I created this example because I had the issue mentioned in #5704. That is working (oninit is firing when navigating in the quicklaunch) now so this issue can be closed.

@ghost ghost added Needs: Attention 👋 Original poster responded to request for feedback, awaiting attention from Microsoft / community. and removed Needs: Author Feedback Awaiting response from the original poster of the issue. Marked as stale if no activity for 7 days. labels Mar 4, 2021
@waaromikniet waaromikniet reopened this Mar 11, 2021
@waaromikniet
Copy link
Author

waaromikniet commented Mar 11, 2021

I have tested on one of my older tenants and there I still see the oninit() is fired only once when switching between lists in the quicklaunch.

Does this mean that this is by design? And I should use another route to display a item command button in my list?

@AJIXuMuK
Copy link
Collaborator

AJIXuMuK commented Oct 1, 2021

@waaromikniet - sorry for the long delay.
onInit is fired when the command set is initialized. For example, when you navigate to a list for the first time.
At that moment your commands will be "attached" to the list and will be available for use.
You can change the visibility of the commands in onListViewUpdated or onExecute later on if needed.

@AJIXuMuK AJIXuMuK closed this as completed Oct 1, 2021
@ghost
Copy link

ghost commented Oct 9, 2021

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 Oct 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:spfx-extensions Category: SharePoint Framework Extensions Needs: Attention 👋 Original poster responded to request for feedback, awaiting attention from Microsoft / community. type:question Question... if answered, will be tagged as such.
Projects
None yet
Development

No branches or pull requests

4 participants