-
Notifications
You must be signed in to change notification settings - Fork 8
fix(builder): include iframe padding in the frame's content origin #700
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ffe53b7
fix(builder): include iframe padding in the frame's content origin
mobeenabdullah 36e5711
fix(builder): measure the frame inset in one place, and correct every…
mobeenabdullah f403f7f
test(builder): check test discovery from outside the globs being checked
mobeenabdullah 7ddeb23
chore(builder): add the lockstep changeset for the frame inset fix
mobeenabdullah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --- | ||
| "nextly": patch | ||
| "create-nextly-app": patch | ||
| "@nextlyhq/admin": patch | ||
| "@nextlyhq/admin-css": patch | ||
| "@nextlyhq/blocks-engine": patch | ||
| "@nextlyhq/blocks-react": patch | ||
| "@nextlyhq/ui": patch | ||
| "@nextlyhq/adapter-drizzle": patch | ||
| "@nextlyhq/adapter-postgres": patch | ||
| "@nextlyhq/adapter-mysql": patch | ||
| "@nextlyhq/adapter-sqlite": patch | ||
| "@nextlyhq/storage-s3": patch | ||
| "@nextlyhq/storage-uploadthing": patch | ||
| "@nextlyhq/storage-vercel-blob": patch | ||
| "@nextlyhq/plugin-form-builder": patch | ||
| "@nextlyhq/plugin-page-builder": patch | ||
| "@nextlyhq/plugin-seo": patch | ||
| "@nextlyhq/plugin-sdk": patch | ||
| "@nextlyhq/eslint-config": patch | ||
| "@nextlyhq/prettier-config": patch | ||
| "@nextlyhq/telemetry": patch | ||
| "@nextlyhq/tsconfig": patch | ||
| "@nextlyhq/builder": patch | ||
| --- | ||
|
|
||
| Correct the frame content origin to include the iframe's padding, and measure that inset in one place. | ||
|
|
||
| An iframe's nested viewport begins at the content box, so padding displaces it exactly as a border does. Callers built the inset from `clientLeft`/`clientTop`, which report the border alone, so every frame-local point mapped toward the border by the scaled padding. `frameInsetOf` is now exported as the single reader, and both the README recipe and the `FrameGeometry` documentation name it instead of restating arithmetic three call sites had already got wrong. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /** | ||
| * The one place a frame's inset is READ from the DOM. | ||
| * | ||
| * `geometry.ts` deliberately takes plain numbers so the mapping can be | ||
| * exercised without a browser. That leaves one question it cannot answer, and | ||
| * it is the question every caller gets wrong: which measurements add up to the | ||
| * offset between a frame's border box and its content viewport. | ||
| * | ||
| * Answering it in prose did not work. The contract was documented as | ||
| * `clientLeft`/`clientTop`, three call sites followed that recipe, and all | ||
| * three were wrong by the padding — because an iframe's nested viewport begins | ||
| * at the CONTENT box, so padding displaces it exactly as a border does. A | ||
| * recipe a caller applies is a recipe a caller can misapply; a function they | ||
| * call is not. | ||
| * | ||
| * Kept in its own module rather than folded into `geometry.ts` so that the | ||
| * arithmetic stays testable without a DOM. This is the edge; that is the pure | ||
| * part. | ||
| * | ||
| * @module geometry-dom | ||
| */ | ||
|
|
||
| import type { FrameInset } from "./geometry"; | ||
|
|
||
| /** | ||
| * How far a frame's content viewport sits inside its border box. | ||
| * | ||
| * Border plus padding, in the frame's own untransformed CSS pixels — which is | ||
| * what {@link FrameInset} means and what `frameContentOrigin` scales. | ||
| * | ||
| * `clientLeft`/`clientTop` report the border alone. Padding comes from the | ||
| * computed style because there is no element property that carries it, and a | ||
| * non-pixel value (a percentage, `auto`) resolves to pixels there too. | ||
| */ | ||
| export function frameInsetOf(frame: HTMLIFrameElement): FrameInset { | ||
| const style = frame.ownerDocument.defaultView?.getComputedStyle(frame); | ||
| // A frame detached from its document has no view and therefore no computed | ||
| // padding. Its border is still readable, so report what is knowable rather | ||
| // than guessing a padding that would silently displace every mapped point. | ||
| const paddingLeft = style === undefined ? 0 : parseFloat(style.paddingLeft); | ||
| const paddingTop = style === undefined ? 0 : parseFloat(style.paddingTop); | ||
| return { | ||
| left: frame.clientLeft + (Number.isFinite(paddingLeft) ? paddingLeft : 0), | ||
| top: frame.clientTop + (Number.isFinite(paddingTop) ? paddingTop : 0), | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.