Skip to content

Change Selected value for OptionButton when last item is deleted.#106254

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
chsoen:fix-105582
May 26, 2025
Merged

Change Selected value for OptionButton when last item is deleted.#106254
Repiteo merged 1 commit into
godotengine:masterfrom
chsoen:fix-105582

Conversation

@chsoen
Copy link
Copy Markdown
Contributor

@chsoen chsoen commented May 10, 2025

Note: undoing the deletion of the last item will not update selected. As far as I could tell, undoing adds back the item that was deleted.
This lead me to conclude that there is no way of undoing the selected value without being able to determine the add was part of an undo.

@chsoen chsoen requested a review from a team as a code owner May 10, 2025 19:20
@KoBeWi KoBeWi added this to the 4.5 milestone May 10, 2025
@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented May 19, 2025

This only works if you delete the last element, but you can still delete more elements at once and cause invalid button state.

@chsoen
Copy link
Copy Markdown
Contributor Author

chsoen commented May 21, 2025

This only works if you delete the last element, but you can still delete more elements at once and cause invalid button state.

Thanks for the review!
I made a new commit addressing this hopefully. Whenever the current selected value is more than the new size, it will default to selecting the last item in the list (-1 if there are no items). I only tested it with clearing the entire list; I'm not sure if there is some other way of removing items from the list I don't know about.

@KoBeWi
Copy link
Copy Markdown
Member

KoBeWi commented May 23, 2025

The commits need to be squashed.

I only tested it with clearing the entire list; I'm not sure if there is some other way of removing items from the list I don't know about.

item_count can be changed from code.

@Repiteo Repiteo merged commit 5186987 into godotengine:master May 26, 2025
20 checks passed
@Repiteo
Copy link
Copy Markdown
Contributor

Repiteo commented May 26, 2025

Thanks! Congratulations on your first merged contribution! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Visual bug in OptionButton

3 participants