Repository navigation
fix(chat): show checked state on omp's checkbox select #451
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
Merged
andrebrait
merged 7 commits into
ompweb-dev:main
from
andrebrait:fix/ask-checkbox-state
Nov 12, 2026
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5adff18
fix(chat): show checked state on omp's checkbox select
andrebrait 79afe15
test(chat): assert checkbox state via accessible names; drop stray bu…
andrebrait ebd0695
fix(chat): send checkbox toggles at once in the composer
andrebrait 57438ed
fix(chat): take one answer per select request until the next arrives
andrebrait 3b32257
fix(chat): disable select controls until omp sends the next request
andrebrait 09c9833
docs(changelog): drop the duplicated checkbox-state entry left by the…
andrebrait 9180390
fix(i18n): complete Traditional Chinese labels after rebase
andrebrait File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -235,7 +235,8 @@ export function ExtensionDialog({ | |
| attached = false, | ||
| }: { | ||
| request: ExtensionDialogRequest; | ||
| onRespond: (request: ExtensionDialogRequest, response: ExtensionDialogResponse) => void; | ||
| /** Resolves `false` when the answer could not be sent, so the panel takes another answer. */ | ||
| onRespond: (request: ExtensionDialogRequest, response: ExtensionDialogResponse) => void | Promise<boolean>; | ||
| /** Render as a composer panel instead of a full-chat overlay. */ | ||
| attached?: boolean; | ||
| }) { | ||
|
|
@@ -247,6 +248,10 @@ export function ExtensionDialog({ | |
| // `pointerType` of the latest press: the pointer media query only describes | ||
| // the primary pointer, not the one pressing now. | ||
| const pressPointerRef = useRef<string | null>(null); | ||
| // omp takes one answer per request id and the panel stays up until the next request arrives, so the | ||
| // select controls are disabled in that window instead of sending a tap omp would silently drop. | ||
| const [answeredId, setAnsweredId] = useState<string | null>(null); | ||
| const awaitingNext = request.method === "select" && answeredId === request.id; | ||
| const [askDrafts, setAskDrafts] = useState(() => initialAskDrafts(request)); | ||
| const viewportMaxHeight = useViewportMaxHeight(); | ||
| const { touchTargets } = useTouchTargets(); | ||
|
|
@@ -278,9 +283,16 @@ export function ExtensionDialog({ | |
| // task, so the phone keyboard closes once instead of flashing as the | ||
| // focused field disappears from under it. | ||
| const respond = (response: ExtensionDialogResponse) => { | ||
| if (request.method === "select") { | ||
| if (awaitingNext) return; | ||
| setAnsweredId(request.id); | ||
| } | ||
| const active = document.activeElement; | ||
| if (active instanceof HTMLElement && panelRef.current?.contains(active)) active.blur(); | ||
| onRespond(request, response); | ||
| const id = request.id; | ||
| void Promise.resolve(onRespond(request, response)).then((sent) => { | ||
| if (sent === false) setAnsweredId((current) => current === id ? null : current); | ||
| }); | ||
| }; | ||
| const cancel = () => respond({ cancelled: true }); | ||
|
|
||
|
|
@@ -415,13 +427,19 @@ export function ExtensionDialog({ | |
| )} | ||
| {request.method === "select" && ( | ||
| <div style={{ display: "grid", gap: 8 }}> | ||
| {request.options.map((option) => { | ||
| {request.options.map((option, index) => { | ||
| const selected = selectedOption === option; | ||
| const checkbox = request.selectionMarker === "checkbox" && index < (request.markableCount ?? request.options.length); | ||
| const checked = checkbox && (request.checkedIndices?.includes(index) ?? false); | ||
|
andrebrait marked this conversation as resolved.
Resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test comment on PR diff file |
||
| // A checkbox toggle goes out at once even when attached: staging it for Next would let the | ||
| // next row (often "Done selecting") silently replace it, and a stray toggle is undone by one tap. | ||
| const stage = attached && !checkbox; | ||
| return ( | ||
| <button | ||
| key={option} | ||
| onClick={() => attached ? setSelectedOption(option) : respond({ value: option })} | ||
| aria-pressed={attached ? selected : undefined} | ||
| onClick={() => stage ? setSelectedOption(option) : respond({ value: option })} | ||
|
andrebrait marked this conversation as resolved.
Resolved
|
||
| disabled={awaitingNext} | ||
| aria-pressed={stage ? selected : undefined} | ||
| style={{ | ||
| width: "100%", | ||
| padding: "7px 10px", | ||
|
|
@@ -438,7 +456,9 @@ export function ExtensionDialog({ | |
| onMouseEnter={attached ? undefined : (e) => { e.currentTarget.style.background = "var(--bg-hover)"; }} | ||
| onMouseLeave={attached ? undefined : (e) => { e.currentTarget.style.background = "var(--bg-panel)"; }} | ||
| > | ||
| {checkbox && <span aria-hidden="true" style={{ marginRight: 6, color: checked ? "var(--accent)" : "var(--text-dim)" }}>{checked ? "☑" : "☐"}</span>} | ||
|
andrebrait marked this conversation as resolved.
Resolved
|
||
| {option} | ||
| {checkbox && <span className="sr-only">, {t(checked ? "chatWindow.optionChecked" : "chatWindow.optionUnchecked")}</span>} | ||
|
andrebrait marked this conversation as resolved.
Resolved
|
||
| </button> | ||
| ); | ||
| })} | ||
|
|
@@ -712,7 +732,7 @@ export function ExtensionDialog({ | |
| ) : (request.method === "select" && attached) || request.method === "ask" ? ( | ||
| <button | ||
| onClick={submitValue} | ||
| disabled={!canSubmit} | ||
| disabled={!canSubmit || awaitingNext} | ||
| style={{ | ||
| padding: "6px 10px", | ||
| minHeight: touchTargets === "accessible" ? 44 : undefined, | ||
|
|
||
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.