microsoft / fast

The adaptive interface system for modern web experiences.
https://www.fast.design
Other
9.25k stars 590 forks source link

feat: add placeholder to FASTSelect #6853

Closed brianchristopherbrady closed 3 months ago

brianchristopherbrady commented 10 months ago

Add placeholder to FASTSelect

Add placeholder functionality to the FASTSelect component to align with how native HTML select elements handle placeholder text.

Expected Behavior

When a placeholder attribute is added to the FASTSelect component, it should dynamically render a hidden and disabled option element to display the placeholder text. If the placeholder attribute is undefined or empty, no placeholder option should be rendered.

Current Behavior

Currently, the FAST Select component does not provide a built-in way to display a placeholder when no items are selected specifically in multiple select mode. This feature would improve the user experience by providing a clear indication of the expected input or prompt the user to make a selection when multiple items can be chosen.

Possible Solution

Implement placeholder support by dynamically creating a hidden and disabled option element inside the FASTSelect component whenever a placeholder attribute is present and not empty. This option will contain the text passed to the placeholder attribute.

Context

The absence of placeholder functionality in FASTSelect limits its usability and alignment with native select features. Having this feature would improve the user experience by providing an indication of the kind of selection that should be made. This change won't alter current behavior if the placeholder attribute is not used but enhances functionality if it is used.

Example

image

janechu commented 3 months ago

Unfortunately @microsoft/fast-foundation is being deprecated, refer to #6955. I see this was mentioned in a PR, we will be addressing open PRs and merging what we can before we snap an archive branch to preserve the latest state of Foundation, however to bring us up to date I am closing out issues.