specify / specify7

Specify 7
https://www.specifysoftware.org/products/specify-7/
GNU General Public License v2.0
60 stars 36 forks source link

Forms and Record Sets don't switch from/to read-only mode even if gear icon does #2767

Open realVinayak opened 1 year ago

realVinayak commented 1 year ago

Describe the bug It seems like the gear icon in the Record Sets and Forms listen to the changes to read-only mode from other tabs, however, the change in the other tab doesn't update the page itself. Thus, the gear icon says it is in the read-only mode (based on another tab) but the page isn't in the read-only mode.

The issue is in 7.8.2 and edge

To Reproduce Steps to reproduce the behavior:

  1. Open a form and open another (or same) record set or form in another tab
  2. Enable read-only mode in the first form.
  3. The gear icon in another tab says it is in read-only mode but the page isn't.

Expected behavior The form/record set in the second tab should have been updated. Also, the save button in the form/record set is still visible even if the component is in the read-only mode (but doesn't do anything) and the user is still able to make changes to the component even if the read-only mode is enabled.

Further, if the user makes a lot of changes to the form but doesn't save them and goes into read-only mode from another tab, then since the first form didn't update the layout (the user still sees editable fields and the save button) they lose those changes.

An easy fix (but harsh on user) would be to refresh the page whenever the form / record set goes into read-only mode. An easier-on-the-user fix would be to check if the user made any changes to the form before going to the read-only mode (even if they went into read-only mode from another tab)

Screenshots I went into read-only mode from another tab in both of the screenshots. Editable fields are still visible even if I'm in the read-only mode editable field still visible if the user is in readonly mode Readonly fields are still visible even if I'm not in the read-only mode readonly fields visible even if the user isn't in readonly fields

Test Panel Link https://purherb-v782.test.specifysystems.org/ https://purherb-edge.test.specifysystems.org/

maxpatiiuk commented 1 year ago

Not sure how likely this is in production, but here is why it happens: As soon as you change the read-only mode, there is logic in there to reload the page. Need to instead move that logic into a separate place, and have that place be called by both direct and indirect changes to prefs.

Same bug would probably happen for UI language change and schema language change

realVinayak commented 1 year ago

Yep, the UI language change and schema language change are only reflected when the user reloads (if they changed the language from another tab). Each change that causes a reload (read-only mode will be one of them) will have a URL to redirect to and we just call it in prefs and read-only mode.

emenslin commented 1 month ago

The main problem of this is fixed however when you have the 2 tabs open and change one to read only it will remove 'data entry' from the navigation bar but if you switch to the other tab 'data entry' will still be on the navigation bar. And then if you disable read only from the second tab 'data entry' will still be gone from the first tab. Not sure if it should be it's own issue but I figured I would just include it here

https://github.com/specify/specify7/assets/150940840/f9574315-6cc6-4759-b2a4-2576ba61aad5