Skip to content

fix: break circular reference between split and split-area #453

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 1 commit into from
Aug 30, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
input,
isDevMode,
} from '@angular/core'
import { SplitComponent } from '../split/split.component'
import { SPLIT_AREA_CONTRACT, SplitComponent } from '../split/split.component'
import { createClassesString, mirrorSignal } from '../utils'
import { SplitAreaSize, areaSizeTransform, boundaryAreaSizeTransform } from '../models'

Expand All @@ -19,6 +19,12 @@ import { SplitAreaSize, areaSizeTransform, boundaryAreaSizeTransform } from '../
exportAs: 'asSplitArea',
templateUrl: './split-area.component.html',
styleUrl: './split-area.component.css',
providers: [
{
provide: SPLIT_AREA_CONTRACT,
useExisting: SplitAreaComponent,
},
],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class SplitAreaComponent {
Expand Down
7 changes: 5 additions & 2 deletions projects/angular-split/src/lib/split/split.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Component,
ElementRef,
HostBinding,
InjectionToken,
NgZone,
Renderer2,
booleanAttribute,
Expand All @@ -17,7 +18,7 @@ import {
untracked,
} from '@angular/core'
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'
import { SplitAreaComponent } from '../split-area/split-area.component'
import type { SplitAreaComponent } from '../split-area/split-area.component'
import { Subject, filter, fromEvent, map, pairwise, skipWhile, startWith, switchMap, take, takeUntil, tap } from 'rxjs'
import {
ClientPoint,
Expand Down Expand Up @@ -61,6 +62,8 @@ interface DragStartContext {
areaAfterGutterIndex: number
}

export const SPLIT_AREA_CONTRACT = new InjectionToken<SplitAreaComponent>('Split Area Contract')

@Component({
selector: 'as-split',
standalone: true,
Expand All @@ -83,7 +86,7 @@ export class SplitComponent {
/**
* @internal
*/
readonly _areas = contentChildren(SplitAreaComponent)
readonly _areas = contentChildren(SPLIT_AREA_CONTRACT)
protected readonly customGutter = contentChild(SplitGutterDirective)
readonly gutterSize = input(this.defaultOptions.gutterSize, {
transform: numberAttributeWithFallback(this.defaultOptions.gutterSize),
Expand Down
Loading