aehrc / smart-forms

React-based form renderer implementing Structured Data Capture (SDC) FHIR specification
https://smartforms.csiro.au
Apache License 2.0
33 stars 11 forks source link

Re-population not working properly on smaller screens #860

Closed fongsean closed 2 months ago

fongsean commented 2 months ago

Describe the bug On larger screen sizes when hitting the Repopulate Form button located on the side bar, the "Select items to be re-populated" dialog appears if there are items to be re-populated.

However on smaller screen sizes where the Repopulate Form button is located in the hover menu (bottom right), it always show the "Form is up to date" dialog.

After some debugging, it seems like the error is caused by the automatic closing and re-opening of the hover menu. At the moment, the itemsToRepopulate state is located on the button itself. That means when the hover menu closes, the itemsToRepopulate state is destroyed, which then always results in an empty itemsToRepopulate state when it re-opens - which is why we always get "Form is up to date".

Potential solutions There is a need to re-factor how theitemsToRepopulate state is stored, we could leverage a global state management store instead of keeping the state local to the re-pop button.

Expected behavior In both cases, the correct rpopulation-related dialogs should be displayed consistently.

fongsean commented 2 months ago

Resolved by #895