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

feat: add ability to Expand/Collapse All #260

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

weyert
Copy link
Contributor

@weyert weyert commented Jul 26, 2024

Motivation and Context

Our documentation consumers wished to have the ability to quickly expand or collapse all the collapsible rows of the schema.

Description

This introduces a new property named showExpandAll (defaults to false) that display a button that allows to easily expand or collapse all rows.

The button shows up in both the breadcrumbs toolbar as above the top schema row.

Replace jotai related deprecated functions to the suggested new alternative functions to avoid the spamming of deprecation warnings in the developer console.

How Has This Been Tested?

This has been tested via fork of the component at work as part of our API reference documentation.

Screenshot(s)/recordings(s)

CleanShot 2024-07-26 at 19 01 49

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

This introduces a new property named `showExpandAll` (defaults to `false`)
that display a button that allows to easily expand or collapse all rows.

The button shows up in both the breadcrumbs toolbar as above the top schema row.

Replace `jotai` related deprecated functions to the suggested new alternative
functions to avoid the spamming of deprecation warnings in the developer console.
{showExpandAll ? (
<HStack w="full" fontFamily="mono" fontSize="sm" lineHeight="none" bg="canvas-pure" px="px" color="light">
<Box flex={1}>&nbsp;</Box>
<Button pl={1} mr={1} size="sm" appearance="minimal" onClick={onCollapseExpandAll}>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to only show this button when the schema as any properties with schema definition that can be expanded/collapsed.

How can I detect this?

@@ -150,7 +149,7 @@ function ScrollCheck() {
const elementRef = React.useRef<HTMLDivElement>(null);

const isOnScreen = useIsOnScreen(elementRef);
const setShowPathCrumbs = useUpdateAtom(showPathCrumbsAtom);
const setShowPathCrumbs = useSetAtom(showPathCrumbsAtom);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to get right of jotai deprecation message in the console

@@ -39,7 +38,9 @@ export const SchemaRow: React.FunctionComponent<SchemaRowProps> = React.memo(
viewMode,
} = useJSVOptionsContext();

const setHoveredNode = useUpdateAtom(hoveredNodeAtom);
const setHoveredNode = useSetAtom(hoveredNodeAtom);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change to get right of jotai deprecation message in the console

@@ -67,6 +68,14 @@ export const SchemaRow: React.FunctionComponent<SchemaRowProps> = React.memo(
const validations = isRegularNode(schemaNode) ? schemaNode.validations : {};
const hasProperties = useHasProperties({ required, deprecated, validations });

React.useEffect(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couldn't think of a better way to ensure the internal state of the row is in sync

@weyert
Copy link
Contributor Author

weyert commented Aug 28, 2024

Any more changes needed?

@weyert
Copy link
Contributor Author

weyert commented Sep 23, 2024

Any news on this PR? Love to have it merged so I don't need mess around with a internal fork :)

@john-tipper
Copy link

What’s needed please to get this merged? We use this library as it’s brilliant but the deprecation warnings are killing our user monitoring and make the console unusable. We’d dearly like to not have to fork this internally - if there aren’t objections to this PR, please could we have this merged and released at the earliest opportunity?

@lovekaizen
Copy link

lovekaizen commented Oct 29, 2024

This library is awesome and has become an instrumental piece of a project at work. Unfortunately, we've had to fork simply to overcome these deprecation warnings, as they're quite noisy. Wondering what is needed to get this PR merged... or if it's OK to create a new PR reducing the scope of these changes to focus on updating the deprecated jotai methods, so that can be merged instead?

@drjonnicholson
Copy link

+1 for getting rid of the deprecation warnings. If ready please merge :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants