Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't allow interactions with URL in Aztec text blocks. #1375

Merged
merged 17 commits into from
Oct 1, 2019

Conversation

SergioEstevao
Copy link
Contributor

Fixes #1373

This PR adds a new delegate method to avoid that interaction with URL attributes happens.
From the documentation it looks this delegate existed since iOS 10, but only with iOS 13 it became a problem. Maybe by default now if no delegate method is implemented the system assumes a true answer?

To test:

  • Start the demo app
  • Tap on any link that exists on the content
  • Make sure that the app is not switched to Safari and tries to open the link there.

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

@SergioEstevao SergioEstevao added the [Type] Bug Something isn't working label Sep 20, 2019
@SergioEstevao SergioEstevao added this to the Open Beta milestone Sep 20, 2019
Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe by default now if no delegate method is implemented the system assumes a true answer?

I see in the docs that: Links in text views are interactive only if the text view is selectable but noneditable. That is, if the value of the UITextViewisSelectable property is true and the isEditable property is false.

At the moment when it is called, I can see that isEditable is true.
And in fact, on iOS 12 it is not assuming false by default, but it is never called.

Might this be an iOS 13 bug?


A drawback of this solution is that links became completely unresponsive also for selection. As an example in the last example block, that is a list block with links, it's not possible to select any of the list items, or set the cursor anywhere in between by tapping.

I tested a fast workaround, something like this:

    func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
        let position = characterRange.location as NSNumber
        setSelection(start: position, end: position)
        return false
    }

and it (kind of) works, but still not as nice as it was before. It will just set the cursor at the beginning of the link.

@SergioEstevao
Copy link
Contributor Author

@etoledom I'm able to force touch and drag the cursor on the links, are you able to do that with your solution above?

@etoledom etoledom self-requested a review September 25, 2019 08:52
Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @SergioEstevao - This works a lot better!

Sadly is not as good as it was before, but since this is a workaround of an iOS bug I think its fine. Not sure if we have any other options anyway, so ✅

I spotted a weird behavior, it might be related to #1161 (or not).

  • When I tap on a link, the cursor goes to the beginning of the linked text ✅
  • The link toolbar button is not selected (✅ I guess?)
  • Pressing the toolbar button shows an empty link bottom sheet (✅ according with ⬆️ )
  • Dismissing the bottom-sheet will remove the link from the linked text (❌)

links_bug

Let me know if you think that this is not worth fixing on this PR. We can try tackle this separately.

@koke
Copy link
Member

koke commented Sep 27, 2019

I think I'm missing something here, but wouldn't it be enough to implement that delegate method to always return false?

@SergioEstevao
Copy link
Contributor Author

@koke that was my first solution but the problem then is that the link text will be completely non interactive, if you tap on it, it will not move the cursor to it...

This is a bad bug from iOS 13...

@SergioEstevao
Copy link
Contributor Author

@etoledom I fixed the bug you detected for link removal, can you give it another spin?

@koke
Copy link
Member

koke commented Sep 30, 2019

Then I must be missing something because I tried without the selection workaround and I'm seeing the same interactions: video

@etoledom
Copy link
Contributor

@koke could you check if the delegate method is being called?

And what iOS version are you testing on? Maybe this bug has been already fixed on the latest iOS 13.1 release. 🤔

@SergioEstevao
Copy link
Contributor Author

SergioEstevao commented Sep 30, 2019 via email

@koke
Copy link
Member

koke commented Sep 30, 2019

I was testing with Xcode 11.1 GM and iOS 13.1

@etoledom
Copy link
Contributor

Just updated my testing device to the latest 13.1 ("Seed 4" from the beta program) and now it is behaving as @koke described.

The delegate override is still needed but just returning false is enough to make it behave as it did before. 👍

There's also an iOS v13.1.1 🤔

@koke
Copy link
Member

koke commented Sep 30, 2019

Also related, I came across this PR because I was investigating this other issue and it caught my attention wordpress-mobile/WordPress-iOS#12568

@etoledom
Copy link
Contributor

@etoledom I fixed the bug you detected for link removal, can you give it another spin?

Working good now! 🎉

Let's update the PR to make it work properly with the released iOS 13.1 version 👍

@koke
Copy link
Member

koke commented Sep 30, 2019

👍 Checked the numbers and it seems 13.0 is currently at 6% and trending down, so by the time this gets released, it could be pretty low.

Screen Shot 2019-09-30 at 11 10 29

Copy link
Contributor

@etoledom etoledom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on iOS v13.1 and v12.4 and works well on both.
Couldn't test on iOS v13.0, but the workaround works well on an older buggy 13.1 release 👍

The link removal fix from WordPress/gutenberg#17631 works well on both iOS and Android 🎉

@marecar3
Copy link
Contributor

Hey @SergioEstevao,
Please, can we mention this fix in RELEASE-NOTES?

@etoledom
Copy link
Contributor

etoledom commented Oct 1, 2019

We should probably merge #1393 first?

@SergioEstevao SergioEstevao merged commit 638c72e into develop Oct 1, 2019
@SergioEstevao SergioEstevao deleted the issue/1373_tap_links_opens_safari branch October 1, 2019 09:35
SergioEstevao added a commit that referenced this pull request Oct 1, 2019
…pens_safari

Don't allow interactions with URL in Aztec text blocks.
# Conflicts:
#	gutenberg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tapping on links on GB editor makes it navigate away from the editor
4 participants