Fix focus management issues due to incorrectly discarding modalboxes.

Review Request #13923 — Created June 3, 2024 and submitted

Information

Djblets
release-5.x

Reviewers

The recent changes to fix modalbox focus management with multiple
modalboxes on screen had a couple of bugs with modalbox instance
management that led to over-aggressive focus control.

The code to remove a modalbox from the list was actually doing two
things:

  1. Removing all modalboxes after the modalbox's index, not just the one
    we wanted to remove.

  2. Taking the discarded modalboxes and setting that as the new array.

This resulted in the latest modalbox (and any after it) being the new
set of modalboxes, and ensuring focus on elements outside of that list
would always be stolen and returned to the now-defunct modalboxes. That
issue manifested in Review Board, where attempting to edit a field after
closing the Review Dialog would fail.

We now splice the entry out correctly, and discard the list of removed
modalboxes.

Tested the repro case:

  1. Click Edit Review
  2. Click Cancel
  3. Edit a field.

This worked as expected. I added console logs for the modalBoxes array
during this process and verified we had the correct state after closing
modalboxes.

I also verified the above with nested modalboxes (Edit Review -> Delete
confirmation dialog), ensuring state was correct.

Unit tests pass.

Summary ID
Fix focus management issues due to incorrectly discarding modalboxes.
The recent changes to fix modalbox focus management with multiple modalboxes on screen had a couple of bugs with modalbox instance management that led to over-aggressive focus control. The code to remove a modalbox from the list was actually doing two things: 1. Removing all modalboxes after the modalbox's index, not just the one we wanted to remove. 2. Taking the discarded modalboxes and setting that as the new array. This resulted in the latest modalbox (and any after it) being the new set of modalboxes, and ensuring focus on elements outside of that list would always be stolen and returned to the now-defunct modalboxes. That issue manifested in Review Board, where attempting to edit a field after closing the Review Dialog would fail. We now splice the entry out correctly, and discard the list of removed modalboxes.
f1aefc3a7cbd3740bc7fe03ed3ca33af0699cf37
david
  1. Ship It!
  2. 
      
maubin
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to release-5.x (9e92595)