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

Click handler on hyperlink is not working #15

Closed
paramadharmika opened this issue Aug 18, 2021 · 3 comments
Closed

Click handler on hyperlink is not working #15

paramadharmika opened this issue Aug 18, 2021 · 3 comments
Labels
more information requested Need additional information

Comments

@paramadharmika
Copy link

Hi, thank you for the awesome plugin.

I have data coming from contentful and some part of the data passed to Hyperlink class looks like this:
{nodeType: hyperlink, content: [{nodeType: text, value: This is a text, marks: [], data: {}}], data: {uri: https://www.domain.com}}

ISSUE

With current implementation on Hyperlink class,

  • When setting text in this line: it will always have empty value
  • Therefore the tap gesture recognizer in this line is not being "called", because its impossible to click on an empty text

SOLUTION

  • Change the implementation on this line to be text: (node['content'][0])['value']
  • Remove the need to put children, therefore deleting line since its duplicating the above suggestion

Do you have any other thoughts on this?

@localpcguy
Copy link
Collaborator

That is exactly how our links look coming through from Contentful, and the code is working as intended (shows the text, text is clickable, we're able to format it, etc.) This is a widget we use as is from this plugin, without overriding or theming it. I believe it's important to maintain the recursive nature of how the children work (each nested content block in turn is given to a child function to process until done) and not to dive manually into the upcoming content blocks unless absolutely necessary.

Are you maybe providing a custom Hyperlink widget that was originally based on this one? That's fine if so, but we can't support custom widget implementations. Beyond that though, I'm not sure where the issue is. This widget code processes the Hyperlink content blocks in order properly given JSON the same as what you provided.

For reference, here's a sample of the Contentful object from one of our apps, which appears to follow the same structure as the JSON you shared.

{
    "data": { "uri": "https://www.aLink.com/" },
    "content": [
      {
        "data": {},
        "marks": [],
        "value": "Link Text",
        "nodeType": "text"
      }
    ],
    "nodeType": "hyperlink"
}

@localpcguy localpcguy added the more information requested Need additional information label Aug 18, 2021
@paramadharmika
Copy link
Author

Previously the app could not open links provided in hyperlinks (using the same structure as you mentioned). I've reverted the changes and now it works as expected.

I'm closing this issue now and thanks for the quick response

@LeifDan01
Copy link

This was probably a configuration issue with url_launcher. Checkout https://pub.dev/packages/url_launcher#configuration

I seemed to be having a similar issue. For me it was launching on iOS but not Android. Digging in it was getting a false on it's canLaunchUrl check. Had to update the AndroidManifest.xml to get it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more information requested Need additional information
Projects
None yet
Development

No branches or pull requests

3 participants