fix(textinput/passwordinput): apply aria-describedby to hint text

* Aria-describedby

Resolves base aria-describedby attribute from #1633.

* Update PasswordInput.svelte
This commit is contained in:
Carson McCue 2023-02-19 11:53:00 -08:00 committed by GitHub
commit b435be4f12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View file

@ -89,6 +89,7 @@
const ctx = getContext("Form");
$: isFluid = !!ctx && ctx.isFluid;
$: helperId = `helper-${id}`;
$: errorId = `error-${id}`;
$: warnId = `warn-${id}`;
</script>
@ -122,6 +123,7 @@
</label>
{#if !isFluid && helperText}
<div
id="{helperId}"
class:bx--form__helper-text="{true}"
class:bx--form__helper-text--disabled="{disabled}"
class:bx--form__helper-text--inline="{inline}"
@ -167,7 +169,13 @@
bind:this="{ref}"
data-invalid="{invalid || undefined}"
aria-invalid="{invalid || undefined}"
aria-describedby="{invalid ? errorId : warn ? warnId : undefined}"
aria-describedby="{invalid
? errorId
: warn
? warnId
: helperText
? helperId
: undefined}"
id="{id}"
name="{name}"
placeholder="{placeholder}"

View file

@ -95,6 +95,7 @@
};
$: isFluid = !!ctx && ctx.isFluid;
$: helperId = `helper-${id}`;
$: errorId = `error-${id}`;
$: warnId = `warn-${id}`;
</script>
@ -182,7 +183,13 @@
data-invalid="{invalid || undefined}"
aria-invalid="{invalid || undefined}"
data-warn="{warn || undefined}"
aria-describedby="{invalid ? errorId : warn ? warnId : undefined}"
aria-describedby="{invalid
? errorId
: warn
? warnId
: helperText
? helperId
: undefined}"
disabled="{disabled}"
id="{id}"
name="{name}"
@ -219,6 +226,7 @@
</div>
{#if !invalid && !warn && !isFluid && !inline && helperText}
<div
id="{helperId}"
class:bx--form__helper-text="{true}"
class:bx--form__helper-text--disabled="{disabled}"
class:bx--form__helper-text--inline="{inline}"