UUI icon indicating copy to clipboard operation
UUI copied to clipboard

useForm and useLock - allow to decide which URL changes to trigger lock

Open jakobz opened this issue 1 year ago • 0 comments

Description

Sometimes, we may encounter cases where not every URL change implies that the user is leaving the page. For example, if we have an editable table with table state stored in the URL, a change in this state (e.g., sorting change) does not necessarily trigger a page exit. To determine which URL changes should be handled via useLock, we need to add the nextLocation parameter to the before-leave callback. Then, the application can decide if this URL change leads to the form being left, or if we can simply return Promise.resolve(true), indicating that the process should redirect without displaying any modals

Describe the solution you'd like

export interface UseLockOptions {
    /** Callback which will be called on router change */
    beforeLeave?: (nextLocation: Link, currentLocation: Link) => Promise<boolean>;

    //lockQueryChange: boolean;
}

jakobz avatar Mar 27 '24 12:03 jakobz