Skip to content

Commit 2d80de0

Browse files
michaldudakDaniel Rabe
authored and
Daniel Rabe
committed
[docs] Explain how the error prop works in the Unstyled Input (mui#35171)
1 parent 23600d1 commit 2d80de0

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

docs/translations/api-docs/input-unstyled/input-unstyled.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"defaultValue": "The default value. Use when the component is not controlled.",
99
"disabled": "If <code>true</code>, the component is disabled. The prop defaults to the value (<code>false</code>) inherited from the parent FormControl component.",
1010
"endAdornment": "Trailing adornment for this input.",
11-
"error": "If <code>true</code>, the <code>input</code> will indicate an error. The prop defaults to the value (<code>false</code>) inherited from the parent FormControl component.",
11+
"error": "If <code>true</code>, the <code>input</code> will indicate an error by setting the <code>aria-invalid</code> attribute on the input and the <code>Mui-error</code> class on the root element. The prop defaults to the value (<code>false</code>) inherited from the parent FormControl component.",
1212
"id": "The id of the <code>input</code> element.",
1313
"maxRows": "Maximum number of rows to display when multiline option is set to true.",
1414
"minRows": "Minimum number of rows to display when multiline option is set to true.",

packages/mui-base/src/InputUnstyled/InputUnstyled.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ InputUnstyled.propTypes /* remove-proptypes */ = {
229229
*/
230230
endAdornment: PropTypes.node,
231231
/**
232-
* If `true`, the `input` will indicate an error.
232+
* If `true`, the `input` will indicate an error by setting the `aria-invalid` attribute on the input and the `Mui-error` class on the root element.
233233
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
234234
*/
235235
error: PropTypes.bool,

packages/mui-base/src/InputUnstyled/InputUnstyled.types.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export interface MultiLineInputUnstyledProps {
5757
}
5858

5959
export type InputUnstyledOwnProps = (SingleLineInputUnstyledProps | MultiLineInputUnstyledProps) &
60-
UseInputParameters & {
60+
Omit<UseInputParameters, 'error'> & {
6161
'aria-describedby'?: string;
6262
'aria-label'?: string;
6363
'aria-labelledby'?: string;
@@ -79,6 +79,11 @@ export type InputUnstyledOwnProps = (SingleLineInputUnstyledProps | MultiLineInp
7979
* Trailing adornment for this input.
8080
*/
8181
endAdornment?: React.ReactNode;
82+
/**
83+
* If `true`, the `input` will indicate an error by setting the `aria-invalid` attribute on the input and the `Mui-error` class on the root element.
84+
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
85+
*/
86+
error?: boolean;
8287
/**
8388
* The id of the `input` element.
8489
*/

packages/mui-base/src/InputUnstyled/useInput.types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface UseInputParameters {
1111
*/
1212
disabled?: boolean;
1313
/**
14-
* If `true`, the `input` will indicate an error.
14+
* If `true`, the `input` will indicate an error by setting the `aria-invalid` attribute.
1515
* The prop defaults to the value (`false`) inherited from the parent FormControl component.
1616
*/
1717
error?: boolean;

0 commit comments

Comments
 (0)