Skip to content

Commit 6c8fe49

Browse files
authored
docs: followup for after initial release (adobe#9492)
1 parent 6be9a11 commit 6c8fe49

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

packages/dev/s2-docs/pages/react-aria/Virtualizer.mdx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ export default Layout;
33

44
import docs from 'docs:react-aria-components';
55
import {GroupedPropTable} from '../../src/PropTable';
6+
import {InlineAlert, Heading, Content} from '@react-spectrum/s2';
67

78
export const tags = ['windowing', 'list', 'grid', 'infinite'];
89
export const description = 'Renders a scrollable collection of data using customizable layouts.';
@@ -41,6 +42,11 @@ for (let i = 0; i < 5000; i++) {
4142

4243
Virtualizer uses <TypeLink links={docs.links} type={docs.exports.Layout} /> objects to determine the position and size of each item, and provide the list of currently visible items. When using a Virtualizer, all items are positioned by the `Layout`, and CSS layout properties such as flexbox and grid do not apply.
4344

45+
<InlineAlert variant="notice" maxWidth={600}>
46+
<Heading>Virtualized components must have a defined size</Heading>
47+
<Content>This may be an explicit CSS `width` and `height`, or an implicit size (e.g. percentage or `flex`) bounded by an ancestor element. Without a bounded size, all items will be rendered to the DOM, negating the performance benefits of virtualized scrolling.</Content>
48+
</InlineAlert>
49+
4450
### List
4551

4652
`ListLayout` supports layout of items in a vertical stack. Rows can be fixed or variable height. When using variable heights, set the `estimatedRowHeight` to a reasonable guess for how tall the rows will be on average. This allows the size of the scrollbar to be calculated.

packages/dev/s2-docs/src/searchUtils.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {type Library, TAB_DEFS} from './constants';
1212
// @ts-ignore
1313
// eslint-disable-next-line monorepo/no-internal-import
1414
import NoSearchResults from '@react-spectrum/s2/illustrations/linear/NoSearchResults';
15-
import {Page} from '@parcel/rsc';
15+
import {Page, TocNode} from '@parcel/rsc';
1616
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
1717
import {style} from '@react-spectrum/s2/style' with {type: 'macro'};
1818
import {useSettings} from './SettingsContext';
@@ -136,13 +136,41 @@ export function stripMarkdown(description: string | undefined): string {
136136
return (description || '').replace(/\[(.*?)\]\(.*?\)/g, '$1');
137137
}
138138

139+
/**
140+
* Gets all of the subheadings underneath a heading within the Table of Contents.
141+
*/
142+
function getToCSubheadings(TocNode: TocNode, headings: string[]): string[] {
143+
headings.push(TocNode.title);
144+
145+
for (let node of TocNode.children) {
146+
getToCSubheadings(node, headings);
147+
}
148+
149+
return headings;
150+
}
151+
139152
/**
140153
* Transforms a page into a ComponentItem for search/display.
141154
*/
142155
export function transformPageToComponentItem(page: Page): ComponentItem {
156+
// get all headings on a page and add them a tags for the search feature
157+
let filterTags = new Set(['Content', 'Example', 'Examples', 'API', 'Accessibility', 'Events', 'Features', 'Introduction', 'Interface']);
158+
let Toc = page.tableOfContents;
159+
let headings: string[] = [];
160+
if (Toc) {
161+
for (let node of Toc) {
162+
let subHeadings: string[] = getToCSubheadings(node, []);
163+
headings.push(...subHeadings);
164+
}
165+
}
166+
let allTags = (page.exports?.tags || page.exports?.keywords as string[]) || [];
167+
let relatedPages = (page.exports?.relatedPages?.map(page => page.title)) || [];
168+
allTags.push(...headings, ...relatedPages);
169+
allTags = allTags.filter(tags => (!filterTags.has(tags) && !tags.startsWith('Testing')));
170+
143171
const title = getPageTitle(page);
144172
const section: string = getSearchSection(page);
145-
const tags: string[] = (page.exports?.tags || page.exports?.keywords as string[]) || [];
173+
const tags: string[] = allTags;
146174
const description: string = stripMarkdown(page.exports?.description);
147175
const date: string | undefined = page.exports?.date;
148176
return {

0 commit comments

Comments
 (0)