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

fix: added context in item-template #886

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sagardspeed2
Copy link
Contributor

@sagardspeed2 sagardspeed2 commented Oct 25, 2024

Describe your changes

Added context in item-template of collapsible widget

Screenshots [Optional]

After

image

Issue ticket number and link

Closes #885

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have added tests
  • I have added a changeset pnpm changeset add
  • I have added example usage in the kitchen sink app

Copy link

changeset-bot bot commented Oct 25, 2024

🦋 Changeset detected

Latest commit: dd58363

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@ensembleui/react-kitchen-sink Patch
@ensembleui/react-runtime Patch
@ensembleui/react-preview Patch
@ensembleui/react-starter Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 25, 2024

Visit the preview URL for this PR (updated for commit dd58363):

https://react-kitchen-sink-dev--pr886-885-context-in-item-4y5vbs4w.web.app

(expires Thu, 21 Nov 2024 07:04:11 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 6267897ade2ba783b6db70a53a60fc3946d625e9

Copy link
Contributor

@evshi evshi left a comment

Choose a reason for hiding this comment

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

Please write a test suite to avoid regressions

packages/runtime/src/widgets/Collapsible.tsx Show resolved Hide resolved
packages/runtime/src/widgets/Collapsible.tsx Outdated Show resolved Hide resolved
packages/runtime/src/widgets/Collapsible.tsx Outdated Show resolved Hide resolved
packages/runtime/src/widgets/Collapsible.tsx Outdated Show resolved Hide resolved
packages/runtime/src/widgets/Collapsible.tsx Outdated Show resolved Hide resolved
packages/runtime/src/widgets/Collapsible.tsx Outdated Show resolved Hide resolved
template: CollapsibleItem;
setEvaluated: React.Dispatch<React.SetStateAction<CollapsibleTemplate[]>>;
}): null => {
const evaluatedData = useEvaluate({ ...template }, { context });
Copy link
Contributor

@evshi evshi Nov 14, 2024

Choose a reason for hiding this comment

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

This should only evaluate the key, otherwise you will create additional bindings for label and children attributes you don't need.

prevEvaluated[currentIndex] = { key, label: header, children: content };
return prevEvaluated;
});
}, [currentIndex, evaluatedData, setEvaluated]);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should only check for the key.

]);

setEvaluated((prev) => {
const prevEvaluated = [...prev];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why duplicate the array?

Comment on lines +97 to +100
: EnsembleRuntime.render([unwrapWidget(label)]);

const content = EnsembleRuntime.render([
unwrapWidget(children as string),
Copy link
Contributor

Choose a reason for hiding this comment

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

The children and label are the same across all the items right? This can be unwrapped once and passed in.

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.

No Context in item-template of Collapsible widget
2 participants