GwtMaterialDesign / gwt-material

A Google Material Design wrapper for GWT
https://gwtmaterialdesign.github.io/gmd-core-demo/
Apache License 2.0
410 stars 124 forks source link

Fixed IndexOutOfBoundsException in MaterialCollapsible #1028

Open dieterblancke opened 2 years ago

dieterblancke commented 2 years ago

This should fix an IndexOutOfBoundsException that occurs when executing setActive with an index equal to the amount of widgets.

This error started occuring since this commit afaik: https://github.com/GwtMaterialDesign/gwt-material/commit/60d3d2137aa45e4af9f3b5501d774f86e3d364e8

dieterblancke commented 4 months ago

@kevzlou7979 if you are able to, please clarify as to what the intention is here.

From the issue #998 it seems like it's now intended to have a 0-based index, yet the log message is still there and there is a check for > 0.

Yet by allowing index <= getWidgetCount(), it can also have an IndexOutOfBoundsException when the index == count (the issue we're running into).

It's fixable by either changing the index <= getWidgetCount() to index < getWidgetCount() and changing the index > 0 to index >= 0 or by reverting to a 1-based index.

Feel free to clarify, and I will update the pull request accordingly 😊