Skip to content

fix(ModelessDialog): title propsがReactNodeを受け取れるように修正#5907

Open
Qs-F wants to merge 5 commits into
masterfrom
fix/modeless-dialog/title-can-be-reactnode
Open

fix(ModelessDialog): title propsがReactNodeを受け取れるように修正#5907
Qs-F wants to merge 5 commits into
masterfrom
fix/modeless-dialog/title-can-be-reactnode

Conversation

@Qs-F
Copy link
Copy Markdown
Contributor

@Qs-F Qs-F commented Oct 22, 2025

関連URL

https://smarthr.atlassian.net/browse/SHRUI-1330

概要

ModelessDialogのtitleが意図せずstringのみを許容する様になっていたのを修正

変更内容

  • BaseのPropsとの交差型の適用によりtitleがstring & ReactNode ~> stringになっていた
  • これをPropsWithHTMLAttributes型を導入し、HTMLElement経由のpropsをOmitするようにしたことで解決
  • 以降、HTMLElementの型をベースにする場合はPropsWithHTMLAttributesを使用することを推奨したい

確認方法

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Oct 22, 2025

Open in StackBlitz

npm i https://pkg.pr.new/@smarthr/smarthr-ui-charts@5907
npm i https://pkg.pr.new/smarthr-ui@5907

commit: a45945c

Comment thread packages/smarthr-ui/src/components/Dialog/ModelessDialog/ModelessDialog.tsx Outdated
@Qs-F Qs-F marked this pull request as ready for review October 22, 2025 12:00
@Qs-F Qs-F requested a review from a team as a code owner October 22, 2025 12:00
@Qs-F Qs-F requested review from masa0527 and uknmr and removed request for a team October 22, 2025 12:00
Comment thread packages/smarthr-ui/src/types/ComponentTypes.ts Outdated
Comment thread packages/smarthr-ui/src/types/ComponentTypes.ts Outdated
export const ModelessDialog: FC<
Props & BaseElementProps & VariantProps<typeof classNameGenerator>
> = ({
type ComponentProps = PropsWithHTMLAttributes<
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React の ComponentProps と見間違うかも。FC<> に直接書いちゃうか ModelessDialogProps とするかかと思いました。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reactのComponentProps型はrefを受け取れるかどうか明確ではないため事故の原因になりやすく、慣習的に基本的に使わないべきはずです!あとここはrefを受け取ることが明確ではないため、やるならModelessDialogPropsWithoutRefになりますが、ほかのコンポーネントでも同様の書き方のパターンが出てくるのでComponentPropsが1番良いのではと思っての判断でした

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

他コンポーネントは Props を FC に渡してることが一番多い気がします。
ModelessDialog の Props の名前を変えて、ここを Props とする手もありそうです。
React の ComponentProps 型を使わないのはわかるけど、FC<ComponentProps> だけ見るとうーんってなりました。

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多分認識のズレが起きてそうで

u: ComponentPropsという名前だとReact.ComponentPropsと勘違いするかもだから他の名前にしたほうが良くない?

ってことを言われている気がします。
慣習的に使わないとしても名前がダブるので他の名前にするかFCに直接渡すほう良い、という意見だと思います。
↑であっているとしたら俺も同意見です。

@AtsushiM AtsushiM requested a review from uknmr May 13, 2026 03:24
AtsushiM and others added 3 commits May 13, 2026 12:30
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>
@AtsushiM AtsushiM self-requested a review May 13, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants