Skip to content

Handle a = null in LexicalClickableLinkPlugin - #4447

Closed
jjjkkkjjj wants to merge 1 commit into
meta:mainfrom
jjjkkkjjj:main
Closed

jjjkkkjjj wants to merge 1 commit into
meta:mainfrom
jjjkkkjjj:main

Conversation

@jjjkkkjjj

Copy link
Copy Markdown

I fixed the bug: TypeError: Cannot read property 'href' of null.
This bug may be caused by a variable that can be null. (domGetParent function can return null)
That's why a variable has no attribute href.

I modified a?.href and a?.target using ? operator instead of a.href and a.target.
When the optional ? operator is used, a variable can be undefined. So, I modified next condition with !url instead of url === null || url === ''.

Resolved `TypeError: Cannot read property 'href' of null`
@vercel

vercel Bot commented May 3, 2023 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 3, 2023 7:31am
lexical-playground ❌ Failed (Inspect) May 3, 2023 7:31am

@facebook-github-bot

Copy link
Copy Markdown
Contributor

Hi @jjjkkkjjj!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@jjjkkkjjj jjjkkkjjj changed the title Handle a = null Handle a = null in LexicalClickableLinkPlugin May 3, 2023

@zurfyx zurfyx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! Can you expand on the issue please? Either add some video on the description or file an issue?

url = a.href;
urlTarget = a.target;
// domGetParent can return null
url = a?.href;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can't use ?. besides the playground. You will have to do a explicit check

@jjjkkkjjj

jjjkkkjjj commented May 22, 2023 •

Copy link
Copy Markdown
Author

@zurfyx
Sorry for late response and thank you for checking my PR! You've already merged the similar PR (#4514), I closed this PR.

@jjjkkkjjj jjjkkkjjj closed this May 22, 2023

This branch had an error being deployed

1 failed and 1 active deployments
Preview – lexical — d7fd77a4 Deployed May 3, 2023 by vercel[bot]
Preview – lexical-playground — d7fd77a4 Deployed May 3, 2023 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants