Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Devtools fixes #54912

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

Closed
wants to merge 4 commits into from
Closed
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 @@ -51,7 +51,7 @@ import {ComponentTreeNode} from './interfaces';
import {ngDebugDependencyInjectionApiIsSupported} from './ng-debug-api/ng-debug-api';
import {setConsoleReference} from './set-console-reference';
import {serializeDirectiveState} from './state-serializer/state-serializer';
import {runOutsideAngular} from './utils';
import {runOutsideAngular, unwrapSignal} from './utils';
import {DirectiveForestHooks} from './hooks/hooks';

export const subscribeToClientEvents = (
Expand Down Expand Up @@ -194,7 +194,7 @@ const getNestedPropertiesCallback =
}
let data = current.instance;
for (const prop of propPath) {
data = data[prop];
data = unwrapSignal(data[prop]);
if (!data) {
console.error('Cannot access the properties', propPath, 'of', node);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@ function getLevelDescriptorValue(
const isReadonly = isSignal(prop);
switch (type) {
case PropType.Array:
return prop.map((_: any, idx: number) =>
return value.map((_: any, idx: number) =>
continuation(value, idx, isReadonly, currentLevel + 1, level),
);
case PropType.Object:
return getKeys(prop).reduce(
return getKeys(value).reduce(
(accumulator, propName) => {
if (!ignoreList.has(propName)) {
accumulator[propName] = continuation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,57 @@
(mouseleave)="removeHighlight()"
[style.padding-left]="15 + 15 * node.level + 'px'"
>
<div class="tree-node-info">
@if (node.expandable) {
<button
[style.left]="15 * node.level + 'px'"
(click)="treeControl.toggle(node)"
[attr.aria-label]="'toggle ' + node.name"
>
<mat-icon class="mat-icon-rtl-mirror">
{{ treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}
</mat-icon>
</button>
}
<span class="element-name" [class.angular-element]="isElement(node)">{{ node.name }}</span>

@if (node.directives) {
<span class="dir-names">[{{ node.directives }}]</span>
}
@if (isSelected(node)) {
<span class="console-reference"> == $ng0 </span>
}

@switch(node.hydration?.status) {
@case('hydrated') {
<mat-icon matTooltip="Hydrated" class="hydration">water_drop</mat-icon>
<div class="tree-node-info">
@if (node.expandable) {
<!-- We stop propagration on dblClick to prevent to show the element panel -->
<button
[style.left]="15 * node.level + 'px'"
(click)="treeControl.toggle(node)"
(dblclick)="stopPropagation($event)"
[attr.aria-label]="'toggle ' + node.name"
>
<mat-icon class="mat-icon-rtl-mirror">
{{ treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right' }}
</mat-icon>
</button>
}
@case('skipped') {
<mat-icon matTooltip="Skipped" class="hydration skipped">invert_colors_off</mat-icon>
<span class="element-name" [class.angular-element]="isElement(node)">{{ node.name }}</span>

@if (node.directives) {
<span class="dir-names">[{{ node.directives }}]</span>
}
@case('mismatched') {
<mat-icon matTooltip="Mismatch" class="hydration mismatched">error_outline</mat-icon>
@if (isSelected(node)) {
<span class="console-reference"> == $ng0 </span>
}
}
</div>
@if(node.hydration?.status === 'mismatched' && (node.hydration.expectedNodeDetails || node.hydration.actualNodeDetails)) {
<div class="hydration-error">
@if(node.hydration.expectedNodeDetails) {
<div>Expected Dom:</div>
<pre>{{node.hydration.expectedNodeDetails}}</pre>
}
@if(node.hydration.actualNodeDetails) {
<div>Actual Dom:</div>
<pre>{{node.hydration.actualNodeDetails}}</pre>

@switch (node.hydration?.status) {
@case ('hydrated') {
<mat-icon matTooltip="Hydrated" class="hydration">water_drop</mat-icon>
}
@case ('skipped') {
<mat-icon matTooltip="Hydration skipped" class="hydration skipped">invert_colors_off</mat-icon>
}
@case ('mismatched') {
<mat-icon matTooltip="Hydration mismatch" class="hydration mismatched">error_outline</mat-icon>
}
}
</div>
}
@if (
treeControl.isExpanded(node) &&
node.hydration?.status === 'mismatched' &&
(node.hydration.expectedNodeDetails || node.hydration.actualNodeDetails)
) {
<div class="hydration-error">
@if (node.hydration.expectedNodeDetails) {
<div>Expected Dom:</div>
<pre>{{node.hydration.expectedNodeDetails}}</pre>
}
@if (node.hydration.actualNodeDetails) {
<div>Actual Dom:</div>
<pre>{{node.hydration.actualNodeDetails}}</pre>
}
</div>
}
</div>

</ng-container>

</cdk-virtual-scroll-viewport>
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ElementRef,
EventEmitter,
HostListener,
Input,
Expand Down Expand Up @@ -99,11 +100,13 @@ export class DirectiveForestComponent {
readonly itemHeight = 18;

private _initialized = false;
private resizeObserver: ResizeObserver;

constructor(
private _tabUpdate: TabUpdate,
private _messageBus: MessageBus<Events>,
private _cdr: ChangeDetectorRef,
private elementRef: ElementRef,
) {
this.subscribeToInspectorEvents();
this._tabUpdate.tabUpdate$.pipe(takeUntilDestroyed()).subscribe(() => {
Expand All @@ -114,6 +117,17 @@ export class DirectiveForestComponent {
});
}
});

// In some cases there a height changes, we need to recalculate the viewport size.
this.resizeObserver = new ResizeObserver(() => {
this.viewport.scrollToIndex(0);
this.viewport.checkViewportSize();
});
this.resizeObserver.observe(this.elementRef.nativeElement);
}

ngOnDestroy(): void {
this.resizeObserver.disconnect();
}

subscribeToInspectorEvents(): void {
Expand Down Expand Up @@ -330,6 +344,10 @@ export class DirectiveForestComponent {
}
}

stopPropagation(event: Event): void {
event.stopPropagation();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Is this used anywhere? Was this referenced in the template somewhere and dropped from this commit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah I'm not sure why the change was missing, It's back now.


private _findMatchedNodes(): number[] {
const indexesOfMatchedNodes: number[] = [];
for (let i = 0; i < this.dataSource.data.length; i++) {
Expand Down