gcds-components icon indicating copy to clipboard operation
gcds-components copied to clipboard

feat: Slots for prefix and suffix in components

Open simberman-gc opened this issue 1 year ago • 2 comments

Prerequisites

Describe the feature request.

We would like to be able to put explanatory text directly before or after an input or select within gcds components.

Describe the use case.

Enter the last three digits of your SIN: XXX-XXX-[ ]

image

Describe the preferred solution.

We think this would be best implemented by exposing slots for before-elements or after-elements. Another idea might be exposing an interior template that could be modified by developers.

Describe all alternatives.

  • We can place the explanatory text after the entire gcds-input, but our designers won't like this as much.
  • We can put the gcds-input inside a wrapper with display:inline-block and put the explanatory text to the right side, but if there is an error message then the width of the gcds-input and its label, etc will be restricted. This wouldn't work at all for explanatory text to the left.
  • We can create separate components for label and error, but then we have to manually manage the DOM representing the error, as well as the error state on the input/select.

Provide related code or examples.

No response

Add other relevant resources.

No response

simberman-gc avatar Apr 16 '24 18:04 simberman-gc

We received a similar question about whether "$" could be added to the input (in English it would be ahead of the field, in French after).

There are some known accessibility issues with putting explanatory text after the field. It could get chopped, pushed to the next line, or simply missed. We could explore the accessibility of including unit of measurement in the field/container as static text.

A workaround right now would be to include the unit of measure in the input (or other component) hint text.

SmartMouthWords avatar Apr 17 '24 16:04 SmartMouthWords

Putting the text "inside" the input would be fine by us.

(That being said, I imagine you would have the same accessibility issue whether the text appears inside the input or outside? I'd imagine that your implementation probably has an actual input element somehow inside of it that the helper text will still be outside of? But hey, any reasonable implementation which gets text before and after the user-input space is a-ok.)

simberman-gc avatar Apr 18 '24 13:04 simberman-gc