Skip to content

refactor(hooks): extract composition store from useIsComposing#2716

Open
devmgn wants to merge 2 commits intomainfrom
refactor/use-is-composing-store
Open

refactor(hooks): extract composition store from useIsComposing#2716
devmgn wants to merge 2 commits intomainfrom
refactor/use-is-composing-store

Conversation

@devmgn
Copy link
Copy Markdown
Owner

@devmgn devmgn commented Apr 19, 2026

Summary

  • useIsComposing 内にあった capture/bubble 用の Map ベースのストアを utils/compositionStore に切り出し、フック本体は useSyncExternalStore でストアを選ぶだけの薄い層に整理
  • ストアは React 非依存のため単体テスト可能。購読切れ目で composing フラグをリセットする挙動(購読者不在中に compositionend を取りこぼしても次回マウント時に true を引きずらない)を契約として明示化し、回帰テストを追加
  • フックのテストを describe で階層化(基本動作 / ストア選択 / 購読ライフサイクル / 実ユースケース)。store と重複する観点を削除し、capture パラメトライズは it.for、StrictMode 下のリスナーリークチェック、子要素からの bubbles:true 経路、composing 中 unmount → 再 mount の回帰テストを追加
  • Storybook は capture → target → bubble の発火順を目視確認できるデモに刷新

Test plan

  • pnpm vitest run src/hooks/useIsComposing — 40 件グリーン
  • pnpm check — lint / fmt / knip パス
  • Storybook で IME 入力した際に capture → target → bubble の順序でログが記録されること

🤖 Generated with Claude Code

devmgn and others added 2 commits April 19, 2026 19:43
useIsComposing 内にあった capture/bubble それぞれの Map ベースのストアを独立モジュール (utils/compositionStore) に切り出し、フックは `useSyncExternalStore` でストアを選ぶだけの薄いレイヤーに整理した。ストアは React 非依存になりユニットテストが書きやすく、購読切れ目で composing が漏れない挙動 (Bug A) も契約として明示的に保証される。

あわせてテストを describe ブロックで階層化し、store と重複する観点を削除して整理。Storybook はキャプチャ/バブルの発火順を目視確認できるデモに刷新。

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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