Skip to content
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

Fixed non-working anchors for definitions, made multiple complex schemas more readable #2389

Merged
merged 3 commits into from
Feb 8, 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 @@ -176,8 +176,11 @@ export class OperationDetails {
const apiName = this.routeHelper.getApiName();
const operationName = this.routeHelper.getOperationName();
const graphName = this.routeHelper.getGraphName();
const definitionName = this.routeHelper.getDefinitionName();

if (this.enableScrollTo && (operationName || graphName)) {
if (definitionName) {
this.scrollToDefinition();
} else if (this.enableScrollTo && (operationName || graphName)) {
this.scrollToOperation();
}

Expand Down Expand Up @@ -458,6 +461,12 @@ export class OperationDetails {
headerElement && headerElement.scrollIntoView({ behavior: "smooth", block: "start", inline: "start" });
}

private scrollToDefinition() {
const definitionId = this.router.getHash();
const definitionElement = document.getElementById(definitionId);
definitionElement && definitionElement.scrollIntoView({ behavior: "smooth", block: "start", inline: "start" });
}

@OnDestroyed()
public dispose(): void {
this.router.removeRouteChangeListener(this.onRouteChange);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<span data-bind="text: property.type.combinationType"></span>:
</div>
<!-- ko foreach: { data: property.type.combination, as: 'item' } -->
<!-- ko if: $index() > 0 -->,
<!-- ko if: $index() > 0 -->,<br>
<!-- /ko -->
<!-- ko if: item.displayAs === 'reference' -->
<a class="text-monospace"
Expand Down
7 changes: 7 additions & 0 deletions src/routing/routeHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ export class RouteHelper {
return this.getHashParameter("graph");
}

/**
* Returns ARM resource name of the definition specified in hash parameter of the current route, e.g. "users".
*/
public getDefinitionName(): string {
return this.getHashParameter("definition");
}

/**
* Returns URL of API details page depending on current route.
* @param apiName ARM resource name of the API.
Expand Down
Loading