Skip to content

Commit

Permalink
fix(form): fixed messageProps error from react when disableMessage is…
Browse files Browse the repository at this point in the history
… enabled

I really don't understand why this fixes it since it was `undefined`.
Only seemed to log errors in the browser.
  • Loading branch information
mlaursen committed Nov 22, 2020
1 parent 2443f9a commit e452aff
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/form/src/text-field/useTextField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,24 @@ export function useTextField({
);

const errorIcon = useIcon("error", propErrorIcon);
let messageProps: ProvidedFormMessageProps | undefined;
const props: ProvidedTextFieldProps & {
messageProps?: ProvidedFormMessageProps;
} = {
id,
value,
theme,
error,
required,
pattern,
minLength,
maxLength: disableMaxLength ? undefined : maxLength,
rightChildren: getErrorIcon(errorMessage, error, errorIcon),
onBlur: handleBlur,
onChange: handleChange,
};
if (!disableMessage) {
messageProps = {
props["aria-describedby"] = messageId;
props.messageProps = {
id: messageId,
error,
theme,
Expand All @@ -403,21 +418,7 @@ export function useTextField({

return [
value,
{
"aria-describedby": disableMessage ? undefined : messageId,
id,
value,
theme,
error,
required,
pattern,
minLength,
maxLength: disableMaxLength ? undefined : maxLength,
rightChildren: getErrorIcon(errorMessage, error, errorIcon),
onBlur: handleBlur,
onChange: handleChange,
messageProps,
},
props,
{
reset,
setState,
Expand Down

0 comments on commit e452aff

Please sign in to comment.