fix: prevent errors when embedded in iframe #1964
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After switching EngineeringPaper.xyz over to mathlive from mathquill, I discovered that my blog posts with EngineeringPaper.xyz iframe embeds were no longer functional since MathLive fields are not functional when embedded in an iframe on an outer page that does not itself contain a math field.
See an example page here with mathlive fields in an iframe (scroll down to see the iframe).
Here's the same EngineeringPaper.xyz sheet rendered outside of an iframe using MathLive.
This is the blog page rendered correctly (falling back to the MathQuill implementation).
The issue was the
_boundingRect
static member of theVritualKeyboardProxy
class being used before being initialized. This change initializes the_boundingRect
value, which fixes the iframe issue.I also added a Playwright test to test the virtual keyboard targeting a mathfield in an iframe to ensure that this change does not introduce a regression with using the virtual keyboard to target a math field in an iframe.