Skip to content

Commit 5598b26

Browse files
fix(grid): fix edit overlay for hierarchical grids
1 parent 9fc5b6e commit 5598b26

2 files changed

Lines changed: 21 additions & 17 deletions

File tree

projects/igniteui-angular/grids/core/src/grid.common.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export class IgxGridBodyDirective { }
1818
*/
1919
export interface RowEditPositionSettings extends PositionSettings {
2020
container?: HTMLElement;
21+
clipToVisibleArea?: boolean;
2122
}
2223

2324
/**
@@ -64,8 +65,10 @@ export class RowEditPositionStrategy extends ConnectedPositioningStrategy {
6465
super.position(contentElement, { width: targetElement.clientWidth, height: targetElement.clientHeight },
6566
document, initialCall, targetElement);
6667

67-
// After positioning in the top layer, keep the overlay clipped to the visible grid body.
68-
this.updateContentClip(contentElement);
68+
if (this.settings.clipToVisibleArea) {
69+
// After positioning in the top layer, keep the overlay clipped to the visible grid body.
70+
this.updateContentClip(contentElement);
71+
}
6972
}
7073

7174
private updateContentClip(contentElement: HTMLElement): void {
@@ -98,28 +101,27 @@ export class RowEditPositionStrategy extends ConnectedPositioningStrategy {
98101

99102
private getClippingRect(element: HTMLElement): Pick<DOMRect, 'top' | 'right' | 'bottom' | 'left'> {
100103
const document = element.ownerDocument;
101-
const rect = element.getBoundingClientRect();
102-
// Start with the current grid body, then narrow it by every clipping parent.
104+
const gridBody = element.closest('[igxgridbody]') as HTMLElement || element;
105+
const rect = gridBody.getBoundingClientRect();
106+
// Start with the current grid body, then narrow it by parent grid bodies.
103107
const clippingRect = { top: rect.top, right: rect.right, bottom: rect.bottom, left: rect.left };
104108

105-
let parent = element.parentElement;
109+
let parent = gridBody.parentElement?.closest('[igxgridbody]') as HTMLElement;
106110

107-
// Intersect with clipping ancestors so nested grids respect their parent grid scroll bounds.
108-
while (parent && parent !== document.body && parent !== document.documentElement) {
109-
const style = document.defaultView?.getComputedStyle(parent) ?? parent.style;
110-
const overflow = `${style.overflow}${style.overflowX}${style.overflowY}`;
111+
// Intersect with parent grid bodies so nested grids respect their parent scroll bounds.
112+
while (parent) {
113+
const parentRect = parent.getBoundingClientRect();
111114

112-
// Only ancestors that clip their children should reduce the visible area.
113-
if (/(auto|scroll|hidden|clip)/.test(overflow)) {
114-
const parentRect = parent.getBoundingClientRect();
115+
clippingRect.top = Math.max(clippingRect.top, parentRect.top);
116+
clippingRect.right = Math.min(clippingRect.right, parentRect.right);
117+
clippingRect.bottom = Math.min(clippingRect.bottom, parentRect.bottom);
118+
clippingRect.left = Math.max(clippingRect.left, parentRect.left);
115119

116-
clippingRect.top = Math.max(clippingRect.top, parentRect.top);
117-
clippingRect.right = Math.min(clippingRect.right, parentRect.right);
118-
clippingRect.bottom = Math.min(clippingRect.bottom, parentRect.bottom);
119-
clippingRect.left = Math.max(clippingRect.left, parentRect.left);
120+
if (clippingRect.top >= clippingRect.bottom || clippingRect.left >= clippingRect.right) {
121+
break;
120122
}
121123

122-
parent = parent.parentElement;
124+
parent = parent.parentElement?.closest('[igxgridbody]') as HTMLElement;
123125
}
124126

125127
// Keep the clipping area inside the viewport because popover content is viewport-positioned.

projects/igniteui-angular/grids/grid/src/grid-base.directive.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8143,6 +8143,8 @@ export abstract class IgxGridBaseDirective implements GridType,
81438143
settings = overlay.settings;
81448144
}
81458145
this.rowEditPositioningStrategy.settings.container = this.tbody.nativeElement;
8146+
this.rowEditPositioningStrategy.settings.clipToVisibleArea =
8147+
this.type === 'hierarchical' && (this as GridType).rootGrid !== this;
81468148
const pinned = this._pinnedRecordIDs.indexOf(rowID) !== -1;
81478149
const targetRow = !pinned ?
81488150
this.gridAPI.get_row_by_key(rowID) as IgxRowDirective

0 commit comments

Comments
 (0)