diff --git a/docs/Datagrid.md b/docs/Datagrid.md index 69efc6f8d9c..d7f45abfff7 100644 --- a/docs/Datagrid.md +++ b/docs/Datagrid.md @@ -6,7 +6,7 @@ storybook_path: ra-ui-materialui-list-datagrid--basic # `` -> **Note:** React-admin v5.8.0 introduced a successor to `` called [``](./DataTable.md). It offers a better developer experience by removing child inspection, and avoids 'polluting' the field components with props only serving in datagrid columns (e.g. sortBy, label, etc). Hence, we recommend using `` instead of `` for new projects. `` is of course still available for backward compatibility. +> **Note:** React-admin v5.8.0 introduced a successor to `` called [``](./DataTable.md). It offers a better developer experience by removing child inspection, and avoids 'polluting' the field components with props only serving in datagrid columns (e.g. sortBy, label, etc). Hence, we recommend using `` instead of `` for new projects. `` is of course still available for backward compatibility. If you want to migrate to ``, we offer a [codemod](./DataTable.md#migrating-from-datagrid-to-datatable) that makes it easier. The `` component renders a list of records as a table. It supports sorting, row selection for bulk actions, and an expand panel. It is usually used as a descendant of the [``](./List.md#list) and [``](./ReferenceManyField.md) components. Outside these components, it must be used inside a `ListContext`. diff --git a/docs/js/ra-navigation.js b/docs/js/ra-navigation.js index edd36cf86c2..feb50b68b2d 100644 --- a/docs/js/ra-navigation.js +++ b/docs/js/ra-navigation.js @@ -60,9 +60,15 @@ function buildPageToC() { hasInnerContainers: true, }); - const storybookPathMetaContent = document.querySelector( + const storybookPathMetaElement = document.querySelector( STORYBOOK_PATH_META_SELECTOR - ).content; + ); + let storybookPathMetaContent; + if (storybookPathMetaElement) { + storybookPathMetaContent = document.querySelector( + STORYBOOK_PATH_META_SELECTOR + ).content; + } const tocList = document.querySelector('.toc-list'); if (!tocList || !storybookPathMetaContent) { return; @@ -113,12 +119,24 @@ function replaceContent(text) { ); const newStorybookPathContent = newStorybookPathMeta?.content ?? ''; - document - .querySelector(STORYBOOK_PATH_META_SELECTOR) - .setAttribute('content', newStorybookPathContent); + const storybookPathMetaElement = document.querySelector( + STORYBOOK_PATH_META_SELECTOR + ); + if (storybookPathMetaElement && newStorybookPathContent) { + document + .querySelector(STORYBOOK_PATH_META_SELECTOR) + .setAttribute('content', newStorybookPathContent); + } else if (newStorybookPathContent) { + const metaElement = document.createElement('meta'); + metaElement.setAttribute('name', 'storybook_path'); + metaElement.setAttribute('content', newStorybookPathContent); + document.head.appendChild(metaElement); + } else { + // Remove the meta element if it doesn't exist in the new content + storybookPathMetaElement?.remove(); + } window.scrollTo(0, 0); - buildPageToC(); navigationFitScroll();