[ @sdxc/ui/mixins ]
mirrorSelectedOption
Keeps a <selectedcontent> slot showing the option a <select> has selected, restoring the mirror the browser maintains whenever a re-render of the tree the field sits in clears it.
import { mirrorSelectedOption } from "@sdxc/ui/mixins";Usage
Writes the selected <option>'s content back into the host
<selectedcontent> once a render has committed and left the slot empty.
The platform fills the slot from the selected option, so what it holds belongs
to the browser rather than to the tree the field was rendered in. A re-render of
that tree finds content nobody declared and empties the slot, which leaves the
trigger blank until the next choice is made; writing the option back on commit is
what keeps the two agreeing. A slot holding a consumer's own fallback content is
left alone, since that content is the tree's to own.
Signature
mirrorSelectedOption(): MixinDescriptor<HTMLElement>Examples
<selectedcontent mix={[mirrorSelectedOption()]} />