Skip to content

Add options response seams and bump version to 0.2.0 - #20

Merged
ulsyemr merged 1 commit into
MehmetCelik4:mainfrom
ulsyemr:feat/options-response-seams
Aug 17, 2026
Merged

Add options response seams and bump version to 0.2.0#20
ulsyemr merged 1 commit into
MehmetCelik4:mainfrom
ulsyemr:feat/options-response-seams

Conversation

@ulsyemr

@ulsyemr ulsyemr commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Why

fetchOptions does more than fetch: it sequences requests, drops stale responses, and does the post-render bookkeeping. A host app whose options endpoint returns something other than a Turbo Stream currently has no way to change only the response handling — it has to reimplement the whole method and inherit the drift that comes with a copy.

What

Two extension points, both with today's behaviour as their default:

readOptionsResponse(response)   // => response.text()
renderOptionsResponse(payload)  // => Turbo.renderStreamMessage(payload)

Overriding them keeps the request sequencing, the stale response guard, aria-busy, renderOptionsState, and single-option auto-selection in the base controller.

And a third event, alongside change and advanced-select:change:

advanced-select:options-loaded  →  detail: { name, value, count }

It fires after every successful remote load — eager dependent loads included — once the options are in the DOM and any auto-selection has been applied. count is the number of selectable options, which is enough to react to an empty or single-option result without reading the DOM.

@ulsyemr
ulsyemr merged commit c3fd6f3 into MehmetCelik4:main Aug 17, 2026
1 check passed
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