Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: MessageDialogの内部ロジックを整理する #5320

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AtsushiM
Copy link
Member

関連URL

概要

変更内容

確認方法

@yagimushi yagimushi force-pushed the chore-refactoring-MessageDialog branch from 1a1921d to 37587af Compare January 22, 2025 23:23
Copy link

pkg-pr-new bot commented Jan 22, 2025

Open in Stackblitz

npm i https://pkg.pr.new/kufu/smarthr-ui@5320

commit: 37587af

Comment on lines -27 to -30
if (!active) {
return
if (active) {
onClickClose()
}
onClickClose()
Copy link
Member Author

Choose a reason for hiding this comment

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

早期returnに意味があるほど複雑なロジックではなく、逆に分かりづらいのでifの条件を整えています


return (
// eslint-disable-next-line smarthr/best-practice-for-layouts, smarthr/a11y-heading-in-sectioning-content
<Stack gap={0} as="section" className={wrapper()}>
Copy link
Member Author

Choose a reason for hiding this comment

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

<Stack gap={0} as="section"> は実質 <Section> と同義であり、余計な内部ロジックが実行されるだけだったので置き換えています

Comment on lines +62 to +77
const FooterCluster = React.memo<
Pick<MessageDialogContentInnerProps, 'onClickClose' | 'decorators'> & { className: string }
>(({ onClickClose, decorators, className }) => {
const children = useMemo(
() => decorators?.closeButtonLabel?.(CLOSE_BUTTON_LABEL) || CLOSE_BUTTON_LABEL,
[decorators],
)

return (
<Cluster as="footer" justify="flex-end" className={className}>
<Button onClick={onClickClose} className="smarthr-ui-Dialog-closeButton">
{children}
</Button>
</Cluster>
)
})
Copy link
Member Author

Choose a reason for hiding this comment

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

closeの関数などもmemo化されたもののため、FooterClusterはDialogの開閉で更新されるのみ、open状態ではほぼmemo化された状態が保てるはずです

@AtsushiM AtsushiM marked this pull request as ready for review January 23, 2025 02:04
@AtsushiM AtsushiM requested a review from a team as a code owner January 23, 2025 02:04
@AtsushiM AtsushiM requested review from oti and yuzuru-akiyama and removed request for a team January 23, 2025 02: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.

1 participant