Skip to content
This repository has been archived by the owner on Feb 6, 2023. It is now read-only.

element.getComputedStyle returns null in Firefox iFrame with display:none #1669

Open
drewjenkins opened this issue Feb 26, 2018 · 2 comments
Labels

Comments

@drewjenkins
Copy link

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
When DraftJS calls getLineHeightPx in expandRangeToStartOfLine.js, it uses getComputedStyle, which in Firefox potentially returns null, due to a documented Firefox issue found here https://bugzilla.mozilla.org/show_bug.cgi?id=548397

What is the expected behavior?
Don't assume getComputedStyle will return an object.

Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?
All Firefox

This is a pretty severe bug in our app, since DraftJS is the main place the enduser does their input. We can work around it now by doing what was suggested here https://bugzilla.mozilla.org/show_bug.cgi?id=548397#c8 but it is a pretty hacky workaround

@flarnie
Copy link
Contributor

flarnie commented Feb 27, 2018

Thanks for the great info! Sounds like there could be an easy fix? Would you like to submit a PR?

Also for your awareness - If you are using Draft.js inside of an iframe I think there are other potential problems that you will encounter. It's worth taking a look at #765 and also facebook/react#12037

So while we're working towards full support of rendering inside iframes, there are some known issues with that use case.

@johnmryan
Copy link

Any update on this issue? I am running into a similar problem because of this Firefox API behavior:

https://github.com/facebook/draft-js/blob/main/src/component/selection/setDraftEditorSelection.js#L136

selection is null in Firefox here when the iframe is display:none, so we get a type error here. Would you be willing to review a PR to default to an empty object if the browser returns null for the Selection?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants