Skip to content

Commit

Permalink
Merge pull request #23741 from peppy/fix-manage-collection-commit-on-…
Browse files Browse the repository at this point in the history
…focus-loss

Fix collection name changes not being reflected if enter is not pressed
  • Loading branch information
bdach authored Jun 4, 2023
2 parents d0167cb + eb7586b commit 25d0f0f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,9 @@ public void TestCollectionRenamedExternal()
assertCollectionName(1, "First");
}

[Test]
public void TestCollectionRenamedOnTextChange()
[TestCase(false)]
[TestCase(true)]
public void TestCollectionRenamedOnTextChange(bool commitWithEnter)
{
BeatmapCollection first = null!;
DrawableCollectionListItem firstItem = null!;
Expand Down Expand Up @@ -293,9 +294,19 @@ public void TestCollectionRenamedOnTextChange()
AddStep("change first collection name", () =>
{
firstItem.ChildrenOfType<TextBox>().First().Text = "First";
InputManager.Key(Key.Enter);
});

if (commitWithEnter)
AddStep("commit via enter", () => InputManager.Key(Key.Enter));
else
{
AddStep("commit via click away", () =>
{
InputManager.MoveMouseTo(firstItem.ScreenSpaceDrawQuad.TopLeft - new Vector2(10));
InputManager.Click(MouseButton.Left);
});
}

AddUntilStep("collection has new name", () => first.Name == "First");
}

Expand Down
1 change: 1 addition & 0 deletions osu.Game/Collections/DrawableCollectionListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ private void load()
RelativeSizeAxes = Axes.Both,
Size = Vector2.One,
CornerRadius = item_height / 2,
CommitOnFocusLost = true,
PlaceholderText = collection.IsManaged ? string.Empty : "Create a new collection"
},
}
Expand Down

0 comments on commit 25d0f0f

Please sign in to comment.