Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/cdk-experimental/column-resize/resizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,28 +182,28 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>

private _listenForRowHoverEvents(): void {
const element = this.elementRef.nativeElement!;
const takeUntilDestroyed = takeUntil<boolean>(this.destroyed);

this.eventDispatcher
.resizeOverlayVisibleForHeaderRow(_closest(element, HEADER_ROW_SELECTOR)!)
.pipe(takeUntilDestroyed)
.pipe(takeUntil(this.destroyed))
.subscribe(hoveringRow => {
if (this._isDestroyed) {
return;
}

if (hoveringRow) {
const tooBigToResize =
this.maxWidthPxInternal < Number.MAX_SAFE_INTEGER &&
element.offsetWidth > this.maxWidthPxInternal;
element.classList.toggle(RESIZE_DISABLED_CLASS, tooBigToResize);

if (!tooBigToResize) {
if (!this.overlayRef) {
this.overlayRef = this._createOverlayForHandle();
}

this.overlayRef ??= this._createOverlayForHandle();
this._showHandleOverlay();
}
} else if (this.overlayRef) {
} else {
// todo - can't detach during an active resize - need to work that out
this.overlayRef.detach();
this.overlayRef?.detach();
}
});
}
Expand Down Expand Up @@ -258,7 +258,7 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
private _cleanUpAfterResize(columnSize: ColumnSizeAction): void {
this.elementRef.nativeElement!.classList.remove(OVERLAY_ACTIVE_CLASS);

if (this.overlayRef && this.overlayRef.hasAttached()) {
if (this.overlayRef?.hasAttached()) {
this._updateOverlayHandleHeight();
this.overlayRef.updatePosition();

Expand Down Expand Up @@ -293,18 +293,20 @@ export abstract class Resizable<HandleComponent extends ResizeOverlayHandle>
}

private _showHandleOverlay(): void {
this._updateOverlayHandleHeight();
this.overlayRef!.attach(this._createHandlePortal());
if (!this._isDestroyed) {
this._updateOverlayHandleHeight();
this.overlayRef?.attach(this._createHandlePortal());

// Needed to ensure that all of the lifecycle hooks inside the overlay run immediately.
this.changeDetectorRef.markForCheck();
// Needed to ensure that all of the lifecycle hooks inside the overlay run immediately.
this.changeDetectorRef.markForCheck();
}
}

private _updateOverlayHandleHeight() {
runInInjectionContext(this.injector, () => {
afterNextRender({
write: () => {
this.overlayRef!.updateSize({height: this.elementRef.nativeElement!.offsetHeight});
this.overlayRef?.updateSize({height: this.elementRef.nativeElement!.offsetHeight});
},
});
});
Expand Down
3 changes: 2 additions & 1 deletion src/dev-app/theme-m3.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@use '@angular/material' as mat;
@use '@angular/material-experimental' as matx;

// Plus imports for other components in your app.

Expand Down Expand Up @@ -38,7 +39,7 @@ html {
@include mat.system-level-colors($light-theme);
@include mat.system-level-typography($light-theme);
// TODO(mmalerba): Support M3 for experimental components.
// @include matx.column-resize-theme($light-theme);
@include matx.column-resize-theme($light-theme);
// @include matx.popover-edit-theme($light-theme);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
@use 'sass:map';

@mixin color($theme) {
$resizable-hover-divider: mat.get-theme-color($theme, primary, 600);
$resizable-active-divider: mat.get-theme-color($theme, primary, 600);
$resizable-hover-divider: mat.get-theme-color($theme, primary, 60);
$resizable-active-divider: mat.get-theme-color($theme, primary, 60);

// TODO: these styles don't really belong in the `color` part of the theme.
// We should figure out a better place for them.
Expand Down
Loading