onDisplayModeChanged not called when client page changes display mode
Category
- [x] Bug
Describe the bug
We have some web part that use onDisplayModeChanged to execute code for saving data etc - and they have worked fine for months - until some days ago.
It works fine on two tested tenants, but not on two others.
Steps to reproduce
Create a web part with code in event handler for onDisplayModeChanged, t.ex: MyDisplayModeWebPart.ts
protected onDisplayModeChanged(oldDisplayMode: DisplayMode) { alert("Displaymode changed"); }
-Add wep-part app to SharePoint Apps -Insert web part on å client side page and publish. -Change mode from view to edit mode (click Edit on page toolbar). Now it's expected to see the alert message, but don't. -Now click Publish to publish the page -> trigger display mode change - also expected to show the alert, but don't.
Also - when opening the page for debugging and place a breakpoint in the event handler, the breakpoint isn't hit: -Insert a web part with an onDisplayModeChanged event to a sitepage -In browser debugger add breakpoint on the event -Change page to and from edit mode. No tracepoint pauses exec.
Expected behavior
Code in onDisplayModeChanged is run - alert is shown when entering and leaving edit mode.
Environment details (development & target environment)
- Your Developer Environment: Windows 10
- Target Environment: SharePoint Online
- Framework: Node.js v10
- Browser(s): Edge
- Tooling: SPFx v1.10.0
- Additional details: The more context you can provide, the easier it is (and therefore quicker) to help.
Additional context
Thanks for your contribution! Sharing is caring.
Submission guidelines
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
We are facing same issue for one of custom web part that we are using to save data onDisplayModeChanged method. Is any update on issue Or is there any other solution to save data when page go from Edit mode to Display?
I am also facing same issue.
Same here. It works on workbench but not on a real page
This is still a problem - any update?
Bump. Any plans to fix it in near future?
@andrewconnell (Updated) I've edited the reproduce-steps and provided more info. May it need some other tagging to get attention for a fix on this issue?
@jklevel I can't speak on behalf of Microsoft (I don't work for Microsoft... I just was helping classify new issues for a period of time)
I am also facing this issue. Any update?
Looking into this - sorry for the (long) delay. Will post back w/ updated info.
@patmill Any updates?
Sorry for the delay. Switching to edit mode no longer does an in-line switch of an existing webpart instance, instead the read-mode instance is torn down, and a new edit-mode instance is created. You will want to hook into the on-dispose of the webpart.
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