You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What you were expecting:
Hidden tabs showing Create or Edit do not refresh after 5 minutes if the form is dirty.
What happened instead:
useRefresh() refreshes dirty forms as well as pristine forms, losing the edits. #5152 attempted to fix the bug but has an error in implementation.
Using any Edit form, change a field value in order to dirty the form
Change to a different tab
Wait at least 5 minutes
Return to the original tab
Form will attempt refresh upon return, prompting with the unsaved changes dialog. If not using the warnWhenUnsavedChanges, the unsaved changes are automatically lost.
attempts to remove a listener without {capture: true}. Per MDN, the capture option must match or removal will fail. Thus dirtying the form leaves old listeners that end up triggering the refresh erroneously.
Other information:
To fix, pass {capture: true} to the removeEventListener call
Environment
React-admin version: 3.8.5
Last version that did not exhibit the issue (if applicable): unknown
React version: 16.13.1
Browser: Version 85.0.4183.102 (Official Build) (64-bit) on MacOSX 10.14.6
The text was updated successfully, but these errors were encountered:
carlfreeland
added a commit
to Journey-Builders/react-admin
that referenced
this issue
Sep 25, 2020
What you were expecting:
Hidden tabs showing Create or Edit do not refresh after 5 minutes if the form is dirty.
What happened instead:
useRefresh() refreshes dirty forms as well as pristine forms, losing the edits. #5152 attempted to fix the bug but has an error in implementation.
Steps to reproduce:
Repro can be done with a standard simple example https://codesandbox.io/s/github/marmelab/react-admin/tree/master/examples/simple but you have to open the application in a new browser window to be able to open tabs.
warnWhenUnsavedChanges
, the unsaved changes are automatically lost.Related code:
react-admin/packages/ra-core/src/dataProvider/useRefreshWhenVisible.ts
Line 31 in 19deccf
{capture: true}
while
react-admin/packages/ra-core/src/dataProvider/useRefreshWhenVisible.ts
Line 35 in 19deccf
{capture: true}
. Per MDN, the capture option must match or removal will fail. Thus dirtying the form leaves old listeners that end up triggering the refresh erroneously.Other information:
To fix, pass
{capture: true}
to the removeEventListener callEnvironment
The text was updated successfully, but these errors were encountered: