Skip to content

Commit 6526ebd

Browse files
committed
fix(tasty): optiimize style rendering * 2
1 parent a8d128a commit 6526ebd

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/components/fields/ComboBox/ComboBox.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ describe('<ComboBox />', () => {
189189
});
190190
});
191191

192-
it.skip('should manage selection correctly', async () => {
192+
it('should manage selection correctly', async () => {
193193
const onSelectionChange = jest.fn();
194194

195195
const { getByRole, getAllByRole, queryByRole } = renderWithRoot(

src/tasty/tasty.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,10 @@ function tastyElement<K extends StyleList, V extends VariantMap>(
353353

354354
for (const prop of propsToCheck) {
355355
const key = prop as unknown as string;
356-
if (Object.prototype.hasOwnProperty.call(otherProps as object, key)) {
357-
if (!propStyles) propStyles = {};
356+
357+
if (!propStyles) propStyles = {};
358+
359+
if (key in otherProps) {
358360
(propStyles as any)[key] = (otherProps as any)[key];
359361
delete (otherProps as any)[key];
360362
}
@@ -376,6 +378,8 @@ function tastyElement<K extends StyleList, V extends VariantMap>(
376378
[breakpoints?.join(',')],
377379
);
378380

381+
const propStylesKey = stringifyStyles(propStyles);
382+
379383
// Optimize style computation and cache key generation
380384
const { allStyles, cacheKey, useDefaultStyles } = useMemo(() => {
381385
const hasStyles =
@@ -399,7 +403,7 @@ function tastyElement<K extends StyleList, V extends VariantMap>(
399403
cacheKey: key,
400404
useDefaultStyles: useDefault,
401405
};
402-
}, [styles, propStyles, breakpointsKey]);
406+
}, [styles, propStylesKey, breakpointsKey]);
403407

404408
// Compute rules synchronously; inject via insertion effect
405409
const directResult: RenderResult = useMemo(() => {

0 commit comments

Comments
 (0)