Add incremental search dummy and live input dispatch - #19
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 83401959ba
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| document.addEventListener("input", function(event) { | ||
| var input = event.target; | ||
| if (!(input instanceof HTMLInputElement)) return; | ||
| if (!input.matches("[data-vcr-live-input]")) return; | ||
| var form = input.closest("form[data-vcr-form][data-vcr-live]"); | ||
| if (!form) return; | ||
| var payloadField = form.querySelector('input[name="vcr_msg_payload"]'); | ||
| if (payloadField) { | ||
| var payloadKey = payloadField.dataset.vcrPayloadKey || input.name; | ||
| var payloadValue = input.value || ""; | ||
| payloadField.value = JSON.stringify({ [payloadKey]: payloadValue }); | ||
| } | ||
| var submitter = form.querySelector("[data-vcr-live-submit]"); | ||
| if (submitter) { | ||
| submitter.click(); | ||
| } else if (form.requestSubmit) { |
There was a problem hiding this comment.
Guard against out-of-order responses on live input
Because every input event triggers a submit (submitter.click()), rapid typing can fire multiple concurrent fetches, and the submit handler always replaces the DOM with the last response to resolve. If an earlier request returns after a later one (slow network or server), the UI can be reverted to stale results (e.g., typing “state” shows results for “sta”). Consider aborting the previous request or attaching a monotonically increasing request id and ignoring late responses for data-vcr-live forms.
Useful? React with 👍 / 👎.
概要
vcr_live_inputで入力イベントからディスパッチする最小実装を追加テスト
mise run all(e2eは既存の3001番サーバー再利用で古いテンプレが当たる場合があるので再起動推奨)