Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Button] Fix icon position not being updated when size is not changed
If a button has a WRAP_CONTENT width and after its text is updated but its size does not change, the icon position won't be updated because at the moment when onTextChanged() is called, getLayout() will return null and a new layout to display text will only be recreated in the next onMeasure() call. To fix this issue, the change moves updateIconPosition() from onSizeChanged() to onLayout(), which will always be called after onMeasure() or onSizeChanged() is called, and thus covers both of the cases after the text is updated (the button changes its size or not.) Note: we still need to keep the updateIconPosition() call in onTextChanged(), to cover the case that the button has a fixed width, in which updating text won't trigger remeasuring of the button. Resolves #2553 PiperOrigin-RevId: 427215840
- Loading branch information