Merge pull request #18164 from Joehuu/fix-exit-dialog-bad-state

Fix popup dialog potentially not clicking last button when dismissed
This commit is contained in:
Dan Balasescu 2022-05-09 17:22:03 +09:00 committed by GitHub
commit e9cc3ab54a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 5 deletions

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Screens;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.Leaderboards;
using osu.Game.Overlays;
@ -503,6 +504,22 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("test dispose doesn't crash", () => Game.Dispose());
}
[Test]
public void TestRapidBackButtonExit()
{
AddStep("set hold delay to 0", () => Game.LocalConfig.SetValue(OsuSetting.UIHoldActivationDelay, 0.0));
AddStep("press escape twice rapidly", () =>
{
InputManager.Key(Key.Escape);
InputManager.Key(Key.Escape);
});
pushEscape();
AddAssert("exit dialog is shown", () => Game.Dependencies.Get<IDialogOverlay>().CurrentDialog != null);
}
private Func<Player> playToResults()
{
Player player = null;

View File

@ -100,10 +100,6 @@ namespace osu.Game.Overlays.Dialog
}
}
// We always want dialogs to show their appear animation, so we request they start hidden.
// Normally this would not be required, but is here due to the manual Show() call that occurs before LoadComplete().
protected override bool StartHidden => true;
protected PopupDialog()
{
RelativeSizeAxes = Axes.Both;
@ -272,7 +268,7 @@ namespace osu.Game.Overlays.Dialog
protected override void PopOut()
{
if (!actionInvoked && content.IsPresent)
if (!actionInvoked)
// In the case a user did not choose an action before a hide was triggered, press the last button.
// This is presumed to always be a sane default "cancel" action.
buttonsContainer.Last().TriggerClick();