()
| 222 | }); |
| 223 | |
| 224 | function TextAreaInput() { |
| 225 | // Force re-render when value changes so we update the height. |
| 226 | let {placeholder} = useSlottedContext(AriaTextAreaContext) ?? {}; |
| 227 | let onHeightChange = (input: HTMLTextAreaElement) => { |
| 228 | // TODO: only do this if an explicit height is not given? |
| 229 | if (input) { |
| 230 | let prevAlignment = input.style.alignSelf; |
| 231 | let prevOverflow = input.style.overflow; |
| 232 | // Firefox scroll position is lost when overflow: 'hidden' is applied so we skip applying it. |
| 233 | // The measure/applied height is also incorrect/reset if we turn on and off |
| 234 | // overflow: hidden in Firefox https://bugzilla.mozilla.org/show_bug.cgi?id=1787062 |
| 235 | let isFirefox = 'MozAppearance' in input.style; |
| 236 | if (!isFirefox) { |
| 237 | input.style.overflow = 'hidden'; |
| 238 | } |
| 239 | input.style.alignSelf = 'start'; |
| 240 | input.style.height = 'auto'; |
| 241 | // offsetHeight - clientHeight accounts for the border/padding. |
| 242 | input.style.height = `${input.scrollHeight + (input.offsetHeight - input.clientHeight)}px`; |
| 243 | input.style.overflow = prevOverflow; |
| 244 | input.style.alignSelf = prevAlignment; |
| 245 | } |
| 246 | }; |
| 247 | let {ref} = useSlottedContext(InputContext) ?? {}; |
| 248 | |
| 249 | return ( |
| 250 | <AriaTextArea |
| 251 | ref={mergeRefs(onHeightChange, ref as RefObject<HTMLTextAreaElement | null>)} |
| 252 | // Workaround for baseline alignment bug in Safari. |
| 253 | // https://bugs.webkit.org/show_bug.cgi?id=142968 |
| 254 | placeholder={placeholder ?? ' '} |
| 255 | className={style({ |
| 256 | paddingX: 0, |
| 257 | paddingY: centerPadding(), |
| 258 | minHeight: controlSize(), |
| 259 | boxSizing: 'border-box', |
| 260 | backgroundColor: 'transparent', |
| 261 | color: { |
| 262 | default: 'inherit', |
| 263 | '::placeholder': { |
| 264 | default: 'gray-600', |
| 265 | forcedColors: 'GrayText' |
| 266 | } |
| 267 | }, |
| 268 | fontFamily: 'inherit', |
| 269 | fontSize: 'inherit', |
| 270 | fontWeight: 'inherit', |
| 271 | lineHeight: 'inherit', |
| 272 | flexGrow: 1, |
| 273 | minWidth: 0, |
| 274 | outlineStyle: 'none', |
| 275 | borderStyle: 'none', |
| 276 | resize: 'none', |
| 277 | overflowX: 'hidden' |
| 278 | })} |
| 279 | /> |
| 280 | ); |
| 281 | } |
nothing calls this directly
no test coverage detected