Fix a focus recursion crash with multiple modalboxes on screen.
Review Request #13856 — Created May 14, 2024 and submitted — Latest diff uploaded
Back in 2020, I did some work to add accessibility to
modalBox
, which
involved also ensuring that keyboard input remained restricted to the
box.This ended up causing crashes when there were multiple boxes on the
screen. Any focus within the latest modalbox would cause a previous
modalbox to steal focus, which would cause the latest to steal focus
back, and so on until the browser crashed the attempt.This was only noticeable if you had the JavaScript console open, but is
clearly not ideal.This change updates the behavior to only attempt to steal for the latest
modalbox. Focus management is now performed in a central function, which
only exists once and only while there's a modalbox on screen. An array
of modalboxes is used to track the stack of modalboxes.
Tested the Discard Review modalbox within the Review Dialog modalbox on
both Chrome and Firefox. Verified that focus behavior continued to work,
and that the modalboxes no longer triggered recursion errors during
focus changes or dialog closes.