sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

onDisplayModeChanged not called when client page changes display mode

Open jklevel opened this issue 5 years ago • 13 comments

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

jklevel avatar Dec 11 '20 06:12 jklevel

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

ghost avatar Dec 11 '20 06:12 ghost

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?

BharatKhunti avatar Dec 22 '20 12:12 BharatKhunti

I am also facing same issue.

kalpeshvaghela90 avatar Dec 23 '20 12:12 kalpeshvaghela90

Same here. It works on workbench but not on a real page

Barba76 avatar Dec 29 '20 20:12 Barba76

This is still a problem - any update?

jklevel avatar Feb 19 '21 11:02 jklevel

Bump. Any plans to fix it in near future?

SharePickle avatar Mar 25 '21 19:03 SharePickle

@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 avatar Sep 09 '21 19:09 jklevel

@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)

andrewconnell avatar Sep 09 '21 20:09 andrewconnell

I am also facing this issue. Any update?

RurhiRaj avatar Sep 21 '21 19:09 RurhiRaj

Looking into this - sorry for the (long) delay. Will post back w/ updated info.

patmill avatar Sep 22 '21 18:09 patmill

@patmill Any updates?

jklevel avatar Nov 02 '21 14:11 jklevel

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.

patmill avatar Nov 02 '21 19:11 patmill

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 avatar Nov 10 '21 00:11 ghost