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: AppNavi, BottomFixedArea, MultiComboboxの内部処理を整理する #5441

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

Conversation

AtsushiM
Copy link
Member

@AtsushiM AtsushiM commented Mar 7, 2025

関連URL

概要

変更内容

確認方法

@AtsushiM AtsushiM changed the title chore: Fix format class name generator 12 chore: AppNavi, BottomFixedArea, MultiComboboxの内部処理を整理する Mar 7, 2025
Copy link

pkg-pr-new bot commented Mar 7, 2025

Open in Stackblitz

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

commit: 313094d

Comment on lines +134 to +137
const Description = memo<PropsWithChildren>(
({ children }) =>
children && <p className="smarthr-ui-BottomFixedArea-description">{children}</p>,
)
Copy link
Member Author

Choose a reason for hiding this comment

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

descriptionが変化する可能性は低いため、memo化しています

@yagimushi yagimushi force-pushed the fix-format-class-name-generator-12 branch from 71f25bf to 1edd4ac Compare March 7, 2025 03:00
@AtsushiM AtsushiM marked this pull request as ready for review March 7, 2025 04:30
@AtsushiM AtsushiM requested a review from a team as a code owner March 7, 2025 04:30
@AtsushiM AtsushiM requested review from yt-ymmt and yuzuru-akiyama and removed request for a team March 7, 2025 04:30
@yt-ymmt
Copy link
Contributor

yt-ymmt commented Mar 10, 2025

nits)BottomFixedAreaの型情報、まとめちゃっても良いかも?と思いました。
https://github.com/kufu/smarthr-ui/pull/5441/files#diff-55316d0e0724226df2a2d1140592b7b0127dc62feb825abb821c18e1fc6a13e9R25-R31

export type ButtonElement =
  | FunctionComponentElement<ComponentProps<typeof Button>>
  | FunctionComponentElement<ComponentProps<typeof AnchorButton>>

export type Primary = ButtonElement
export type Secondary = ButtonElement

Copy link
Contributor

@yt-ymmt yt-ymmt left a comment

Choose a reason for hiding this comment

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

細かいところコメントしましたがnitsなのでApproveします!

@yt-ymmt
Copy link
Contributor

yt-ymmt commented Mar 10, 2025

@AtsushiM yuzuru sanがレビュアーになっておりますが、terraformの設定ミスの名残です:pray:
私のレビューのみで良ければこのまま進行いただければと思います。

@AtsushiM
Copy link
Member Author

AtsushiM commented Mar 10, 2025

nits)BottomFixedAreaの型情報、まとめちゃっても良いかも?と思いました。

ああ、全く一緒なんですね
PrimaryとかSecondaryが分離しているのも歴史的背景(元々コンポーネントが別だった)が原因だと思うので、そもそもexportするものをButtonElementにしてしまうのも良さそうです
(コンポーネント外にexportしていないっぽいし)

Comment on lines -282 to -284
if (isComposing) {
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

早期 return では駄目そうでしたか?

Copy link
Member Author

Choose a reason for hiding this comment

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

はい、駄目です。

以前別PRで話した内容と同じ修正ですね。
#5433 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

初見では意図のわかりにくい変更が多かったため、レビューコメントでも問題ので補足入れてもらえると嬉しいです!

Comment on lines +198 to +214
const actualOnDelete = useMemo(() => {
const handlers: Array<(item: ComboBoxItem<T>) => void> = []

if (onDelete) {
handlers.push((item: ComboBoxItem<T>) => onDelete(item))
}
if (onChangeSelected) {
handlers.push((item: ComboBoxItem<T>) =>
onChangeSelected(
selectedItems.filter((selected) => !areComboBoxItemsEqual(selected, item)),
),
)
}

if (handlers.length === 0) {
return NOOP
}
Copy link
Member Author

@AtsushiM AtsushiM Mar 10, 2025

Choose a reason for hiding this comment

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

この関数は何もする必要がないパターンが存在しており、それのチェックを追加しています。
以前の場合、何もする必要がない場合でもrequestAnimationFrameの呼び出しなどは行われていました。
#5433 (comment) と同じ理屈です。

そのうえで、この関数は他の関数内からの呼び出しが存在しており、かつ別ファイルで関数が常にあることを期待している状態だったため、NOOPを返すようにしています。
定数のNOOPを返すことで、他のhookのmemo化も適切に処理されます。

まとめて修正できるならundefinedにしたいところですが一旦ここまでで止めています。

@AtsushiM AtsushiM requested a review from uknmr March 10, 2025 08:48
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