Skip to content

Commit 8190c4b

Browse files
committed
fix scroll to section
1 parent 2f487aa commit 8190c4b

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages/gitbook/src/components/DocumentView/OpenAPI/style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173

174174
.openapi-schema,
175175
.openapi-disclosure {
176-
@apply py-2.5 flex flex-col gap-2 scroll-mt-(--toc-top-offset);
176+
@apply py-2.5 flex flex-col gap-2;
177177
}
178178

179179
.openapi-schema-properties .openapi-schema:last-child {
@@ -182,7 +182,7 @@
182182

183183
/* Schema Presentation */
184184
.openapi-schema-presentation {
185-
@apply flex flex-col gap-1 font-normal;
185+
@apply flex flex-col gap-1 font-normal scroll-mt-(--toc-top-offset);
186186
}
187187

188188
.openapi-schema-properties:last-child {

packages/react-openapi/src/OpenAPISchema.tsx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ function OpenAPISchemaProperty(
6464
const ancestors = new Set(circularRefs.keys());
6565
const alternatives = getSchemaAlternatives(schema, ancestors);
6666

67-
const header = <OpenAPISchemaPresentation context={context} property={property} />;
67+
const header = <OpenAPISchemaPresentation id={id} context={context} property={property} />;
6868
const content = (() => {
6969
if (alternatives?.schemas) {
7070
const { schemas, discriminator } = alternatives;
@@ -105,15 +105,13 @@ function OpenAPISchemaProperty(
105105

106106
if (properties?.length) {
107107
return (
108-
<div id={id} className={clsx('openapi-schema', className)} {...rest}>
109-
<OpenAPIDisclosure
110-
icon={context.icons.plus}
111-
header={header}
112-
label={(isExpanded) => getDisclosureLabel({ schema, isExpanded, context })}
113-
>
114-
{content}
115-
</OpenAPIDisclosure>
116-
</div>
108+
<OpenAPIDisclosure
109+
icon={context.icons.plus}
110+
header={header}
111+
label={(isExpanded) => getDisclosureLabel({ schema, isExpanded, context })}
112+
>
113+
{content}
114+
</OpenAPIDisclosure>
117115
);
118116
}
119117

@@ -365,11 +363,13 @@ function OpenAPISchemaEnum(props: {
365363
* Render the top row of a schema. e.g: name, type, and required status.
366364
*/
367365
export function OpenAPISchemaPresentation(props: {
366+
id?: string;
368367
property: OpenAPISchemaPropertyEntry;
369368
context: OpenAPIClientContext;
370369
circularRefId?: string;
371370
}) {
372371
const {
372+
id,
373373
property: { schema, propertyName, required, isDiscriminatorProperty },
374374
circularRefId,
375375
context,
@@ -379,7 +379,7 @@ export function OpenAPISchemaPresentation(props: {
379379
const example = resolveFirstExample(schema);
380380

381381
return (
382-
<div className="openapi-schema-presentation">
382+
<div id={id} className="openapi-schema-presentation">
383383
<OpenAPISchemaName
384384
schema={schema}
385385
type={getSchemaTitle(schema)}

0 commit comments

Comments
 (0)