Modal buttons freeing the mouse when invisible if a descendant of a ScreenGUI inside another ScreenGUI

Reproduction:

  • Insert a ScreenGUI into StarterGUI (we will call this ScreenGUI A)
  • Insert another ScreenGUI as a child of ScreenGUI A (we will call this ScreenGUI B)
  • Insert an ImageLabel as a child of ScreenGUI B
  • Set Modal of the ImageLabel to True
  • Press F5 to enter test mode.
  • Use the mouse wheel to scroll into first-person mode.

Notice how your mouse is unlocked.

  • Now, set the Enabled property of ScreenGUI B to False

Notice that the ImageLabel is no longer visible, but your mouse is still unlocked.

  • Now, set the Enabled property of ScreenGUI A to False

Notice how now your mouse is now locked.

Expected behavior

The Modal property of a button should only free the mouse if the button is visible on screen.