Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit bd6e302

Browse files
chore(menu-surface): Position surface to the right if the anchor is wider than the surface and is flipped horizontally.
PiperOrigin-RevId: 340245340
1 parent 5511c52 commit bd6e302

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/mdc-menu-surface/foundation.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,8 @@ export class MDCMenuSurfaceFoundation extends MDCFoundation<MDCMenuSurfaceAdapte
400400

401401
const isRtl = this.adapter.isRtl();
402402
const isFlipRtl = this.hasBit(this.anchorCorner, CornerBit.FLIP_RTL);
403-
const hasRightBit = this.hasBit(this.anchorCorner, CornerBit.RIGHT);
403+
const hasRightBit = this.hasBit(this.anchorCorner, CornerBit.RIGHT) ||
404+
this.hasBit(corner, CornerBit.RIGHT);
404405

405406
// Whether surface attached to right side of anchor element.
406407
let isAnchoredToRight = false;

packages/mdc-menu-surface/test/foundation.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,17 @@ describe('MDCMenuSurfaceFoundation', () => {
842842
.toHaveBeenCalledWith({right: 0, top: 0});
843843
});
844844

845+
testFoundation(
846+
'#open Surface is positioned from right side in LTR when corner is flipped horizontally and anchor is wider than menu.',
847+
({foundation, mockAdapter}) => {
848+
initAnchorLayout(mockAdapter, wideTopLeft);
849+
foundation.flipCornerHorizontally();
850+
foundation.open();
851+
jasmine.clock().tick(1); // Run to frame.
852+
expect(mockAdapter.setTransformOrigin).toHaveBeenCalledWith('center top');
853+
expect(mockAdapter.setPosition).toHaveBeenCalledWith({right: 0, top: 0});
854+
});
855+
845856
testFoundation(
846857
'#open Surface is positioned from left side in LTR when corner is flipped horizontally and space is not available on the left side.',
847858
({foundation, mockAdapter}) => {

0 commit comments

Comments
 (0)