Skip to content

Build option elements in the browser with the host class map - #18

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

Build option elements in the browser with the host class map#18
ulsyemr merged 1 commit into
MehmetCelik4:mainfrom
ulsyemr:feat/client-rendered-options

Conversation

@ulsyemr

@ulsyemr ulsyemr commented Aug 17, 2026

Copy link
Copy Markdown
Collaborator

Why

The controller can only work with options the server rendered. Anything that needs to add or replace options in the browser — a host app reacting to a Turbo Stream, or the upcoming appendOption / replaceOptions — has to build the option markup itself, and gets no access to the class map while doing it.

What

The partial now publishes the resolved option, option_check, option_content, and option_description classes on the root element, alongside the ones already published there.

optionElement(option) builds an option element from the option contract, producing the same markup as advanced_select_option_tag — same role, aria state, action wiring, param attributes, and content structure, with classes taken from the host's class map rather than hardcoded:

const select = application.getControllerForElementAndIdentifier(element, "advanced-select")

select.currentOptionsTarget.appendChild(select.optionElement({ id: "7", label: "Item B" }))

@ulsyemr
ulsyemr merged commit a06ac3e 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