Skip to content

Commit

Permalink
Merge pull request #14669 from storybookjs/fix-args-table-sort-prop-w…
Browse files Browse the repository at this point in the history
…hen-using-of

Addon-docs: Fix ArgsTable sorting when using of={Component}
  • Loading branch information
shilman committed Apr 21, 2021
2 parents 773e053 + 8ee062f commit 70fa87e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions addons/docs/src/blocks/ArgsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,10 @@ export const StoryTable: FC<

export const ComponentsTable: FC<ComponentsProps> = (props) => {
const context = useContext(DocsContext);
const { components, include, exclude } = props;
const { components, include, exclude, sort } = props;

const tabs = addComponentTabs({}, components, context, include, exclude);
return <TabbedArgsTable tabs={tabs} />;
return <TabbedArgsTable tabs={tabs} sort={sort} />;
};

export const ArgsTable: FC<ArgsTableProps> = (props) => {
Expand All @@ -222,7 +222,8 @@ export const ArgsTable: FC<ArgsTableProps> = (props) => {
} catch (err) {
mainProps = { error: err.message };
}
return <PureArgsTable {...mainProps} />;

return <PureArgsTable {...mainProps} sort={sort} />;
}

if (components) {
Expand Down
2 changes: 1 addition & 1 deletion examples/cra-ts-kitchen-sink/src/stories/PropsSort.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PropTypes from 'prop-types';

export const PropsSort = () => <div>PropsSort!</div>;
PropsSort.propTypes = {
foo: PropTypes.string,
foo: PropTypes.string.isRequired,
middleWithDefaultValue: PropTypes.string,
bar: PropTypes.string,
endWithDefaultValue: PropTypes.string,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { PropsSort } from './PropsSort';
import { ArgsTable, Meta } from '@storybook/addon-docs/blocks';
import { SortType } from "@storybook/components";

<Meta title="PropsSort" />
<Meta
title="PropsSort"
/>

<ArgsTable of={PropsSort} />
<ArgsTable of={PropsSort} exclude={['foo']} />
<ArgsTable of={PropsSort} sort="alpha" />
<ArgsTable of={PropsSort} sort="requiredFirst" />

0 comments on commit 70fa87e

Please sign in to comment.