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

Support removing array items #237

Merged
merged 3 commits into from
Jun 22, 2023
Merged

Support removing array items #237

merged 3 commits into from
Jun 22, 2023

Conversation

nmanu1
Copy link
Contributor

@nmanu1 nmanu1 commented Jun 20, 2023

Add support for removing existing array literal items. Update the nested props acceptance test to take a screenshot of what array props look like with expression and literal values.

Made an item for consolidating our other "Remove" buttons to use the generic RemovableElement component instead of having a button for each concept in Studio (e.g. removing pages, components, props, etc.).

J=SLAP-2770
TEST=auto, manual

See that clicking the Remove Item button deletes the item and once there are no items, the top-level expression input is enabled again.

@nmanu1 nmanu1 requested a review from oshi97 June 22, 2023 15:35
const generateRemoveItem = useCallback(
(index: number) => () => {
const updatedItems = [...value];
updatedItems.splice(index, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can try toSpliced here!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like support for it is being added in TS, but they haven't released a version that includes it yet

@nmanu1 nmanu1 merged commit 45669c9 into main Jun 22, 2023
@nmanu1 nmanu1 deleted the dev/remove-array-item branch June 22, 2023 18:12
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.

2 participants