Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: Fix slot render functions",
"packageName": "@fluentui/react-utilities",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';

import { omit } from '../utils/omit';
import { SLOT_RENDER_FUNCTION_SYMBOL } from './constants';
import type {
AsIntrinsicElement,
ComponentState,
Expand Down Expand Up @@ -75,16 +76,21 @@ function getSlot<R extends SlotPropsRecord, K extends keyof R>(
return [null, undefined as R[K]];
}

const { children, as: asProp, ...rest } = props;
const {
children,
as: asProp,
[SLOT_RENDER_FUNCTION_SYMBOL]: renderFunction,
...rest
} = props as typeof props & { [SLOT_RENDER_FUNCTION_SYMBOL]?: SlotRenderFunction<R[K]> };

const slot = (
state.components?.[slotName] === undefined || typeof state.components[slotName] === 'string'
? asProp || state.components?.[slotName] || 'div'
: state.components[slotName]
) as React.ElementType<R[K]>;

if (typeof children === 'function') {
const render = children as SlotRenderFunction<R[K]>;
if (renderFunction || typeof children === 'function') {
const render = renderFunction || (children as SlotRenderFunction<R[K]>);
return [
React.Fragment,
{
Expand Down