pegros / PEG_LIST

Set of configurable/actionable LWC list components for Salesforce Lightning UX
MIT License
20 stars 9 forks source link

[feat] sfpegCardCmp - Enforce save on edits before closing the page #50

Open roygre123 opened 1 year ago

roygre123 commented 1 year ago

Hello @pegros , I've been using your amazing PEG component repository for many of my client's use cases. We have encountered a puzzling behavior of the system that I was wondering if you believe that could be solved with PEG. We are trying to enforce standard Salesforce record behavior on screen flows. When a user enters/changes a value in one of the screen's fields and navigates outside of the context of a screen flow (on a lightning page layout) to another tab or out of the focus of the tab that the screen flow is on he should be prompted to choose whether they want to save, discard or cancel the action (same as with a new/update record standard action). Another alternative would be some kind of "Autosave" mechanism if possible. The idea is to minimize the risk of losing precious screen flow data entry updates. Adding an example of the record detail component and a screen flow side by side under the same tab. When editing the record detail component and trying to close the tab without saving it throws the prompt. However, when you edit the screen input fields in the flow and try to close the tab it doesn't warn the user. The client thought/idea was to have a similar experience. Attaching a screen shot and recording. Do you think this is achievable with PEG components/events or if we'll wrap the flow in a LWC container? Is there some way to identify that a flow screen input field has been edited and use the event to create an interaction between the LWC and flow?

roygre123 commented 1 year ago

f7741711-e5e4-458b-ab52-b5377d232c33

pegros commented 1 year ago

Just currently investigating options to address this requirement @@roygre123

For the time being, the option is to display a standard blocking confirm() popup if a sfpegCardCmp component is disconnected while still in edit mode.

Capture d’écran 2023-01-05 à 12 41 55

This option does not prevent the user from losing edits if a browser refresh is triggered.

Once this option is tested OK, solution will be propagated to other components.

pegros commented 1 year ago

I got the explanation about the difference of behaviour between standard and console modes concerning the triggering of the disconnectedCallback().