Skip to content

Commit e452aff

Browse files
committed
fix(form): fixed messageProps error from react when disableMessage is enabled
I really don't understand why this fixes it since it was `undefined`. Only seemed to log errors in the browser.
1 parent 2443f9a commit e452aff

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

packages/form/src/text-field/useTextField.ts

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -389,9 +389,24 @@ export function useTextField({
389389
);
390390

391391
const errorIcon = useIcon("error", propErrorIcon);
392-
let messageProps: ProvidedFormMessageProps | undefined;
392+
const props: ProvidedTextFieldProps & {
393+
messageProps?: ProvidedFormMessageProps;
394+
} = {
395+
id,
396+
value,
397+
theme,
398+
error,
399+
required,
400+
pattern,
401+
minLength,
402+
maxLength: disableMaxLength ? undefined : maxLength,
403+
rightChildren: getErrorIcon(errorMessage, error, errorIcon),
404+
onBlur: handleBlur,
405+
onChange: handleChange,
406+
};
393407
if (!disableMessage) {
394-
messageProps = {
408+
props["aria-describedby"] = messageId;
409+
props.messageProps = {
395410
id: messageId,
396411
error,
397412
theme,
@@ -403,21 +418,7 @@ export function useTextField({
403418

404419
return [
405420
value,
406-
{
407-
"aria-describedby": disableMessage ? undefined : messageId,
408-
id,
409-
value,
410-
theme,
411-
error,
412-
required,
413-
pattern,
414-
minLength,
415-
maxLength: disableMaxLength ? undefined : maxLength,
416-
rightChildren: getErrorIcon(errorMessage, error, errorIcon),
417-
onBlur: handleBlur,
418-
onChange: handleChange,
419-
messageProps,
420-
},
421+
props,
421422
{
422423
reset,
423424
setState,

0 commit comments

Comments
 (0)