Fix behavior of customButton to avoid flicker.