GWT Window.confirm() triggered by onchange of ValueListBox crashing Safari on iPad iOS 7.0.6

StackOverflow https://stackoverflow.com/questions/22116741

  •  18-10-2022
  •  | 
  •  

Question

I recently received a support ticket that some of our web app's functionality is crashing safari on the iPad. This functionality had no problems prior to the latest iOS 7.0.6 update. We have a few GWT ValueListBoxes that change the DOM when their values are changed. Prior to making the changes, we present the user with a Window.confirm() message to inform them of the effects the changes will have and ask whether or not they would still like to proceed. Since the update, the confirm choices do nothing and Safari crashes. This is only happening on the iPad. The functionality works fine on the desktop browsers (IE, Chrome, Firefox, Safari and the Chrome mobile emulator), but crashes safari on the iPad. Is anyone else having this issue?

Here's a screenshot of the crash:SafariCrashOniPad

And here's a sample of the code:

this._view.isPrimaryFoodGen().addValueChangeHandler(new ValueChangeHandler<Boolean>()
{
    @Override
    public void onValueChange(final ValueChangeEvent<Boolean> event)
    {
        @SuppressWarnings("unchecked")
        ValueListBoxWithOldValue<Boolean> vlb = (ValueListBoxWithOldValue<Boolean>)event.getSource();

        if (confirmQuestionChange() ){
            changeGroupAndQuestions(CONSTANTS.PRIMARY_FOOD, event.getValue());
        }
        else {
            vlb.setValue(vlb.getOldValue());
        }
    }
});

public boolean confirmQuestionChange()
{
    if (!this._view.isImageCriteriaQuestionsVisible())
    { //questions aren't currently visible
        return true;
    }

    boolean confirmed = Window.confirm("Changing this response will delete image data already collected. Do you wish to proceed?");
    return confirmed;
}

Any help on a solution for preventing the crash on the iPad would be greatly appreciated. I have tried focusing on another element prior to calling Window.confirm() in hopes that the overlay and the ValueListBox choices would be removed to stop any JS conflicts, but it hasn't worked.

Am I at the mercy of Apple until the next update fixes this? Or is there a viable solution?

Was it helpful?

Solution

OK, so it turns out that since I couldn't find a fix to continue using Window.confirm(), I had to implement a solution by changing the onValueChange() and confirmQuestionChange() methods to use a manually created DialogBox instead of Window.confirm(). It isn't the optimal solution, but Safari does not crash on the iPad anymore and users can get their work done. Here are the code changes:

    this._view.isPrimaryFoodGen().addValueChangeHandler(new ValueChangeHandler<Boolean>()
{
    @Override
    public void onValueChange(final ValueChangeEvent<Boolean> event)
    {
        confirmQuestionChange(CONSTANTS.PRIMARY_FOOD, event);
    }

});

public void confirmQuestionChange(final String question, ValueChangeEvent<Boolean> event)
{
    final ValueListBoxWithOldValue<Boolean> vlb = (ValueListBoxWithOldValue<Boolean>)event.getSource();

    if (!this._view.isImageCriteriaQuestionsVisible())  //questions aren't currently visible, can change them no problem
    { 
        changeGroupAndQuestions(question, vlb.getValue());
    }
    else{
      //the following fix was put in place for issues with Safari on the iPad OPS-76
        final DialogBox dialogBox = new DialogBox();
        dialogBox.setHTML("<center>Changing this response will delete<br />image data already collected.<br />Do you wish to proceed?</center>");
        dialogBox.setAnimationEnabled(true);
        Button yesButton =  new Button("YES");
        Button noButton = new Button("NO");
        HorizontalPanel dialogHPanel = new HorizontalPanel();
        dialogHPanel.setWidth("100%");
        dialogHPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
        dialogHPanel.add(noButton);
        dialogHPanel.add(yesButton);

        noButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                vlb.setValue(vlb.getOldValue());
                dialogBox.hide();
              }
        });

        yesButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                changeGroupAndQuestions(question, vlb.getValue());
                dialogBox.hide();
              }
        });

        // Set the contents of the Widget
        dialogBox.setWidget(dialogHPanel);
        dialogBox.setPopupPosition(180, 425);
        dialogBox.show();
    }
}

Here's a screenshot: enter image description here

As you can see, the ValueListBox options close before the DialogBox appears and the screen no longer locks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top