Skip to content

Commit 2dcb762

Browse files
committed
fix(system): chakra.path d prop
1 parent 5afce28 commit 2dcb762

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

.changeset/little-paws-shout.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,11 @@
22
"@chakra-ui/react": minor
33
---
44

5-
Add `DownloadTrigger` component to help download file contents
5+
- **DownloadTrigger [New]** Add `DownloadTrigger` component to help download
6+
file contents.
7+
8+
- **System**
9+
10+
- Fix issue where passing `d` prop to `chakra.path` adds it to styles not as a
11+
direct attribute.
12+
- Fix issue where responsive semantic tokens did not get applied.

packages/react/src/styled-system/factory.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
import * as React from "react"
2020
import { mergeProps } from "../merge-props"
2121
import { mergeRefs } from "../merge-refs"
22-
import { compact, cx, getElementRef, interopDefault } from "../utils"
22+
import { compact, cx, getElementRef, interopDefault, uniq } from "../utils"
2323
import type { JsxFactory, StyledFactoryFn } from "./factory.types"
2424
import { useChakraContext } from "./provider"
2525
import { isHtmlProp, useResolvedProps } from "./use-resolved-props"
@@ -77,6 +77,14 @@ const Insertion = ({ cache, serialized, isStringTag }: any) => {
7777
return null
7878
}
7979

80+
const exceptionPropMap = {
81+
path: ["d"],
82+
}
83+
84+
const hasProp = (obj: any, prop: string) => {
85+
return Object.prototype.hasOwnProperty.call(obj, prop)
86+
}
87+
8088
const createStyled = (tag: any, configOrCva: any = {}, options: any = {}) => {
8189
if (process.env.NODE_ENV !== "production") {
8290
if (tag === undefined) {
@@ -86,6 +94,12 @@ const createStyled = (tag: any, configOrCva: any = {}, options: any = {}) => {
8694
}
8795
}
8896

97+
if (hasProp(exceptionPropMap, tag)) {
98+
options.forwardProps ||= []
99+
const props = exceptionPropMap[tag as keyof typeof exceptionPropMap]
100+
options.forwardProps = uniq([...options.forwardProps, ...props])
101+
}
102+
89103
const isReal = tag.__emotion_real === tag
90104
const baseTag = (isReal && tag.__emotion_base) || tag
91105

packages/react/src/utils/uniq.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
export const uniq = <T>(...items: T[]) => {
2-
const _items = items.filter(Boolean)
3-
return Array.from(new Set(_items))
1+
export const uniq = <T>(...items: T[][]): T[] => {
2+
const set = items.reduce<Set<T>>((acc, curr) => {
3+
if (curr != null) curr.forEach((item) => acc.add(item))
4+
return acc
5+
}, new Set([]))
6+
return Array.from(set)
47
}

0 commit comments

Comments
 (0)