fix: pak/siteチェックボックスがURL遷移後に実際の選択状態を反映しない不具合を修正 - #190
Merged
Conversation
#189で$paks/$sitesを#[Url]化した際、URLクエリ文字列からの配列ハイドレート
(Livewire\Features\SupportQueryString\BaseUrl)が値を真偽値ではなく文字列
'0'/'1'に変換してしまうことに起因する回帰。
PHP側のarray_filter()(selectedPaks()/selectedSites()で使用)は文字列'0'を
falsy値として扱うため検索フィルタ自体は正しく動作していたが、フロントエンド
に送られるwire:snapshotのJSON上では非空文字列としてtruthyに評価され、
チェックボックスの表示(実際にはLivewireのJS側がJSON値の真偽判定でchecked
状態を決めている)が実際の選択状態を反映しなくなっていた。
boot()で$paks/$sitesを明示的にbool配列へキャストし直すことで補正した。
`Livewire::withQueryParams()`でクエリ文字列付きマウントを再現し、修正前は
実際に失敗する回帰テストを追加。assertSetはゆるい比較('0' == falseは
true)のため検知できず、instance()の値をassertSameで厳密比較する必要が
あった。
Owner
Author
セルフレビュー結果
Pint / PHPStan(level 9) / Rector 全てクリーン。追加の懸念事項なし。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#189 で
$paks/$sitesを#[Url]化した際に生じた回帰です。URLクエリ文字列からの配列ハイドレート(Livewire\Features\SupportQueryString\BaseUrl)が値を真偽値ではなく文字列'0'/'1'に変換してしまいます。PHP側の
array_filter()(selectedPaks()/selectedSites()で使用)は文字列'0'をfalsy値として扱うため検索フィルタ自体は正しく動作していましたが、フロントエンドに送られるwire:snapshotのJSON上では非空文字列としてtruthyに評価され、チェックボックスの表示(Livewireのクライアント側JSがJSON値の真偽判定でchecked状態を決めている)が実際の選択状態を反映しなくなっていました。boot()で$paks/$sitesを明示的にbool配列へキャストし直すことで補正しました。Livewire::withQueryParams()でクエリ文字列付きマウントを再現し、修正前は実際に失敗する回帰テストを追加しています。assertSetはゆるい比較('0' == falseはtrue)のため検知できず、instance()の値をassertSameで厳密比較する必要がありました(実際に修正を一時的に無効化して失敗することを確認済み)。Test plan
./vendor/bin/pint --test./vendor/bin/phpstan analyse(全体、エラーなし)./vendor/bin/rector process --dry-run(提案を適用済み)php artisan test(67件全て通過)wire:snapshotのJSONを直接確認し、修正後は"paks":{"64":false,"128":true,...}のように真偽値として正しくシリアライズされることを確認済み🤖 Generated with Claude Code