Skip to content

Conversation

LukeyBeachBoy
Copy link
Contributor

…portMargin

The overlay directive now accepts two additional (optional parameters) [viewportMarginX] and [viewportMarginY]. You can use these to pass separate margin values for the viewport.

@LukeyBeachBoy LukeyBeachBoy requested a review from a team as a code owner August 9, 2024 12:44
@LukeyBeachBoy LukeyBeachBoy requested review from crisbeto and wagnermaciel and removed request for a team August 9, 2024 12:44
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Aug 9, 2024
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

Can you add a couple of tests to src/cdk/overlay/position/flexible-connected-position-strategy.spec.ts?

@LukeyBeachBoy LukeyBeachBoy force-pushed the feature-cdk-overlay-split-viewport-margin branch 2 times, most recently from 37b5e76 to 0903d6e Compare August 18, 2024 12:24
@LukeyBeachBoy
Copy link
Contributor Author

Can you add a couple of tests to src/cdk/overlay/position/flexible-connected-position-strategy.spec.ts?

Hi, done :)

@LukeyBeachBoy LukeyBeachBoy force-pushed the feature-cdk-overlay-split-viewport-margin branch from 0903d6e to 2a78c90 Compare October 7, 2024 09:34
@LukeyBeachBoy
Copy link
Contributor Author

Hi @crisbeto, could I get another review? Thanks!

* Sets a minimum distance the overlay may be positioned from the left edge of the viewport.
* @param margin Required margin between the overlay and the viewport edge in pixels.
*/
withViewportMarginLeft(margin: number): this {
Copy link
Member

Choose a reason for hiding this comment

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

A couple of notes:

  1. Instead of introducing properties for each direction, we should just change the viewport margin to be something like number | {top: number, bottom: number, start: number, end: number}.
  2. We should use start and end, instead of left and right, because they get inverted in RTL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good points, I've updated the parameter to a union type as suggested as well as renamed left/right -> start/end

@LukeyBeachBoy LukeyBeachBoy force-pushed the feature-cdk-overlay-split-viewport-margin branch from 2a78c90 to 742668a Compare October 7, 2024 11:03
@LukeyBeachBoy LukeyBeachBoy force-pushed the feature-cdk-overlay-split-viewport-margin branch 3 times, most recently from 6804076 to 73539f2 Compare October 9, 2024 07:36
@LukeyBeachBoy
Copy link
Contributor Author

Hi @crisbeto, I updated my tests and everything should build correctly now. Could you review again when you have time?

@@ -0,0 +1 @@
export type ViewportMargin = number | {top?: number; bottom?: number; start?: number; end?: number};
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this file is missing a license header. You can also put the type in one of the existing files.

…portMargin

The overlay directive now accepts two additional (optional parameters) [viewportMarginX] and [viewportMarginY]. You can use these to pass separate margin values for the viewport.
@LukeyBeachBoy LukeyBeachBoy force-pushed the feature-cdk-overlay-split-viewport-margin branch from 73539f2 to 70450b2 Compare October 9, 2024 09:34
@LukeyBeachBoy
Copy link
Contributor Author

@crisbeto Right, sorry. I've moved it to another file now

@LukeyBeachBoy
Copy link
Contributor Author

Is there something else I need to change for this PR? I see the merge status and internal tests are failing but I'm unable to see any details

Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

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

It looks like this broke some internal screenshot tests, but I haven't had the time to debug them. In some of them an autocomplete that is close to the viewport edge was the same width as the trigger, but after the change it's slightly smaller. I suspect the margin might be getting doubled somewhere where previously it wasn't.

@mmalerba mmalerba added the action: merge The PR is ready for merge by the caretaker label Aug 11, 2025
@adolgachev adolgachev added requires: TGP This PR requires a passing TGP before merging is allowed action: global presubmit The PR is in need of a google3 global presubmit presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged labels Sep 24, 2025
} else if (isBoundedByRightViewportEdge) {
left = origin.x;
width = viewport.right - origin.x;
width = viewport.right - origin.x - this._getViewportMarginEnd();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the screenshot diffs @crisbeto mentioned are caused by this line. It previously wasn't accounting for the margin at all in this case, and now it is. This seems like probably just a bug that nobody noticed before so I'm inclined to approve the screenshots

@mmalerba mmalerba added target: patch This PR is targeted for the next patch release target: major This PR is targeted for the next major release and removed target: patch This PR is targeted for the next patch release labels Oct 2, 2025
@mmalerba mmalerba merged commit 82cd076 into angular:main Oct 2, 2025
24 of 26 checks passed
@LukeyBeachBoy
Copy link
Contributor Author

Thanks for the approval!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action: global presubmit The PR is in need of a google3 global presubmit action: merge The PR is ready for merge by the caretaker detected: feature PR contains a feature commit presubmit failures This PR has failures in Google's internal presubmit process and cannot be immediately merged requires: TGP This PR requires a passing TGP before merging is allowed target: major This PR is targeted for the next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants