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: wrap contextual help if primitive #817

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions plugins/ui/src/js/src/widget/WidgetUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
isCallableNode,
CALLABLE_KEY,
wrapTextChildren,
isPrimitive,
} from '../elements/utils/ElementUtils';
import HTMLElementView from '../elements/HTMLElementView';
import { isHTMLElementNode } from '../elements/utils/HTMLElementUtils';
Expand Down Expand Up @@ -160,14 +161,20 @@ export function getComponentForElement(element: ElementNode): React.ReactNode {
const Component = getComponentTypeForElement(newElement);

if (Component != null) {
const props =
const props = { ...newElement.props };
if (
shouldWrapTextChildren.has(newElement[ELEMENT_KEY]) &&
newElement.props?.children != null
? {
...newElement.props,
children: wrapTextChildren(newElement.props.children),
}
: newElement.props;
props?.children != null
) {
props.children = wrapTextChildren(props.children);
}
if (props?.contextualHelp != null && isPrimitive(props.contextualHelp)) {
props.contextualHelp = (
<ContextualHelp>
<Content>{props.contextualHelp}</Content>
</ContextualHelp>
);
}

return <Component {...props} />;
}
Expand Down
Loading