5 votes

Prompt for unsaved changes on iOS?

Tags: ios, feature

I was just writing a different long post here and lost it all because of accidental navigation away from the page. I know the feature to prompt for unsaved changes works on desktop, but is there any way to get it working on iOS?

Edit: maybe another solution would be to save one new topic draft in local storage, and clear the draft data on click of Save or a new Discard/Cancel button? This way if there was data on load of the new topic page, it would still be there.

12 comments

  1. [2]
    Deimos
    Link
    Ah, sorry for the lost post. I filed an issue for this way back in July, but hadn't fixed it yet: https://gitlab.com/tildes/tildes/issues/155 Let me take a look now and see if I can figure out an...

    Ah, sorry for the lost post. I filed an issue for this way back in July, but hadn't fixed it yet: https://gitlab.com/tildes/tildes/issues/155

    Let me take a look now and see if I can figure out an easy way to get it to work.

    7 votes
    1. Neverland
      Link Parent
      Thanks! I searched issues but apparently quite poorly :)

      Thanks! I searched issues but apparently quite poorly :)

      2 votes
  2. [5]
    meghan
    Link
    Safari on iOS does not support onbeforeunload[1]. However, there may be ways to get around it with a combination of other events[2][3]. [1] https://stackoverflow.com/a/6907676/5203655 [2]...
    4 votes
    1. [2]
      Neverland
      Link Parent
      Thanks for the solid reply! And just to clarify, I tried on iOS chrome too, so this is a WebKit issue?

      Thanks for the solid reply! And just to clarify, I tried on iOS chrome too, so this is a WebKit issue?

      1 vote
      1. meghan
        Link Parent
        Yes, all browsers on iOS are required to use WebKit as the engine, per the Apple developer ToS

        Yes, all browsers on iOS are required to use WebKit as the engine, per the Apple developer ToS

        5 votes
    2. [2]
      masochist
      Link Parent
      Is there a site like caniuse which specifies that iOS Safari does not support onbeforeunload? That's where I looked, and they say it's in all modern browsers, not making the iOS distinction which...

      Is there a site like caniuse which specifies that iOS Safari does not support onbeforeunload? That's where I looked, and they say it's in all modern browsers, not making the iOS distinction which is important here.

      1 vote
  3. [5]
    Deimos
    Link
    I just tried making a change that might fix this, but I can't test it myself. @Neverland (or anyone else that's using the site through mobile iOS), could you try entering some text into a comment...

    I just tried making a change that might fix this, but I can't test it myself.

    @Neverland (or anyone else that's using the site through mobile iOS), could you try entering some text into a comment box now and then clicking on a link or pushing back, and see if it stops you from navigating away with a prompt? You may need to force a full refresh first to make sure you have the new javascript.

    3 votes
    1. [4]
      Comment deleted by author
      Link Parent
      1. [3]
        Deimos
        Link Parent
        Thanks for trying (@Neverland too). It looks like this method won't work then (and I've reverted the change I tried). At least as far as I can tell from looking for workarounds so far, it's not...

        Thanks for trying (@Neverland too). It looks like this method won't work then (and I've reverted the change I tried).

        At least as far as I can tell from looking for workarounds so far, it's not even going to be possible to do "pop up a warning before leaving the page" on iOS. I might be able to store the comment and restore it if you come back, but that will require more work since it's an entirely new feature.

        3 votes
        1. Neverland
          (edited )
          Link Parent
          Yeah, I thought some sort of saved draft feature might be needed. Well thanks for investigating more fully. Just my 2c on priority, that is the only thing that is lacking in my Tildes iOS mobile...

          Yeah, I thought some sort of saved draft feature might be needed. Well thanks for investigating more fully.

          Just my 2c on priority, that is the only thing that is lacking in my Tildes iOS mobile experience. So in my mind restoring the draft new_topic would be very nice to have/almost “broken.” It sucks that it would be work, add complexity, and address a need of only iOS users.

          4 votes
        2. [2]
          Comment deleted by author
          Link Parent
          1. Deimos
            Link Parent
            I'd just want to store the text in the browser's storage, not on Tildes's end. I don't think unfinished posts should leave your browser (and if they did, it would probably be through a more...

            I'd just want to store the text in the browser's storage, not on Tildes's end. I don't think unfinished posts should leave your browser (and if they did, it would probably be through a more explicit "drafts"-like feature, which would definitely be opt-in to use).

            4 votes
    2. Neverland
      Link Parent
      It also does not work for me, and I tried in a Chrome incognito tab to make sure I had the latest code.

      It also does not work for me, and I tried in a Chrome incognito tab to make sure I had the latest code.

      1 vote