Skip to content

Buttons on successive AlertScreen renderings are not respected #138

@christiandeange

Description

@christiandeange

When rendering two different AlertScreens in back-to-back render passes, the button contents do not seem to be updated by the AlertContainer properly.

First Rendering Second Rendering
AlertScreen(message = "Starting Checkout...", onEvent = {}) AlertScreen(message = "Waiting for checkout...", buttons = mapOf(NEGATIVE to "Cancel"), onEvent = { ... })
Screenshot_1595382241 Screenshot_1595382242

At first I was able to work around this locally by using some reflection to manually force the buttons to be re-bound to the UI again:

val buttonPanel = dialog.findViewById<ViewGroup>(androidx.appcompat.R.id.buttonPanel)
dialog.javaClass.getDeclaredField("mAlert")
    .let { mAlert ->
      mAlert.isAccessible = true
      mAlert[dialog].javaClass.getDeclaredMethod("setupButtons", ViewGroup::class.java)
          .let { setupButtons ->
            setupButtons.isAccessible = true
            setupButtons(mAlert[dialog], buttonPanel)
          }
    }

Eventually I just decided to implement my own AlertContainer-like container to subvert this entirely.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions