Resolve "C_004_R10 Notes and day query run interaction"
Closes #1268 (closed)
Problem cause
SliderControl
defines a ResizeObserver
in its constructor that fires when the window is resized, calling (down the line) QueryRunComponent.restoreState()
, which slides back to the start of the query run.* When users click on the daily notes textarea
, the keyboard opens on mobile devices, which Firefox Android interprets as a window resize and triggers the ResizeObserver
.
Solution
Skip the ResizeObserver
callback when the virtual keyboard opens.
Afaik, there's no way to check for this directly (Firefox hasn't implemented VirtualKeyboard
so far). I found a workaround that checks if the active element is textarea
or input
and the window width hasn't changed (to accommodate orientation changes). I also needed to manually blur the active element in SliderControl.focus()
to close the keyboard during actual resize events.
This works and doesn't effect behavior on Chrome. The only problem is that the resize event (and thus scrolling to the first slide) is still triggered when the user clicks on another slide while the daily notes textarea is focused (since the textarea then loses focus).
Elisabeth decided we don't want the resize functionality at all, so I completely removed it from the app. This does not negatively affect the HCP monitoring setup.
*The underlying issue seems to be the restoreState()
function. It currently can't access the last viewed/focused slide, so defaults to always scrolling back to the first slide. The same behavior happens in the monitoring setup when a new question is added. I'll leave fixing that to another issue.
I added an e2e test that types in the daily notes, but unsure how useful it is here since this only occurred in one browser, so the test would have also passed before.