Fix an issue that could return wrong index when adding a button

If an alert has a cancel button, by default that button would be at index 0. However, the cancel button index was previously not factored in the calculation of the newly added button index, causing an off-by-one error when adding a button to an alert with a cancel button.