fix(ModelessDialog): title propsがReactNodeを受け取れるように修正#5907
Conversation
commit: |
| export const ModelessDialog: FC< | ||
| Props & BaseElementProps & VariantProps<typeof classNameGenerator> | ||
| > = ({ | ||
| type ComponentProps = PropsWithHTMLAttributes< |
There was a problem hiding this comment.
React の ComponentProps と見間違うかも。FC<> に直接書いちゃうか ModelessDialogProps とするかかと思いました。
There was a problem hiding this comment.
reactのComponentProps型はrefを受け取れるかどうか明確ではないため事故の原因になりやすく、慣習的に基本的に使わないべきはずです!あとここはrefを受け取ることが明確ではないため、やるならModelessDialogPropsWithoutRefになりますが、ほかのコンポーネントでも同様の書き方のパターンが出てくるのでComponentPropsが1番良いのではと思っての判断でした
There was a problem hiding this comment.
他コンポーネントは Props を FC に渡してることが一番多い気がします。
ModelessDialog の Props の名前を変えて、ここを Props とする手もありそうです。
React の ComponentProps 型を使わないのはわかるけど、FC<ComponentProps> だけ見るとうーんってなりました。
There was a problem hiding this comment.
多分認識のズレが起きてそうで
u: ComponentPropsという名前だとReact.ComponentPropsと勘違いするかもだから他の名前にしたほうが良くない?
ってことを言われている気がします。
慣習的に使わないとしても名前がダブるので他の名前にするかFCに直接渡すほう良い、という意見だと思います。
↑であっているとしたら俺も同意見です。
Parameters<FC>[0]はextendsの制約として機能していなかったため削除。 単にPropsとすることで意図を明確化。 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
複数のOmitを一つにまとめ、不要な中間型Propsを削除。 型の意味は変わらず、コードの可読性が向上。 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
関連URL
https://smarthr.atlassian.net/browse/SHRUI-1330
概要
ModelessDialogのtitleが意図せずstringのみを許容する様になっていたのを修正
変更内容
確認方法