From 11c088329494b173cce8bce65dea46fbd1aa4be4 Mon Sep 17 00:00:00 2001 From: Andrew Holloway Date: Wed, 12 Jun 2024 18:14:54 -0500 Subject: [PATCH] fix: handle required disabled field hints (#1990) - update snapshots and tests --- .../InputField/InputField-v2.stories.tsx | 13 +++ src/components/InputField/InputField-v2.tsx | 2 + .../__snapshots__/InputField-v2.test.tsx.snap | 82 +++++++++++++++---- src/components/Select/Select-v2.module.css | 5 ++ src/components/Select/Select-v2.tsx | 14 +++- 5 files changed, 97 insertions(+), 19 deletions(-) diff --git a/src/components/InputField/InputField-v2.stories.tsx b/src/components/InputField/InputField-v2.stories.tsx index 8628cac1b..6cd19a5c9 100644 --- a/src/components/InputField/InputField-v2.stories.tsx +++ b/src/components/InputField/InputField-v2.stories.tsx @@ -122,6 +122,19 @@ export const Required: Story = { }, }; +/** + * Fields can be marked as required. + */ +export const RequiredDisabled: Story = { + args: { + label: 'Input field with fieldNote', + showHint: true, + required: true, + disabled: true, + fieldNote: 'This is a fieldnote for a required input field.', + }, +}; + /** * When not using a visible label with `InputField`, you must apply some time of ARIA label to the component, like `aria-label`. */ diff --git a/src/components/InputField/InputField-v2.tsx b/src/components/InputField/InputField-v2.tsx index 2d8672ae9..3342e9dfc 100644 --- a/src/components/InputField/InputField-v2.tsx +++ b/src/components/InputField/InputField-v2.tsx @@ -249,6 +249,7 @@ export const InputField: InputFieldType = forwardRef( )} {required && showHint && ( InputWithin story renders snapshot 1`] = ` > @@ -156,7 +156,7 @@ exports[` InputWithin story renders snapshot 1`] = `
NoVisibleLabel story renders snapshot 1`] = ` class="input-field__body input-field--has-fieldNote" >
This input field has no visible label
@@ -295,7 +295,7 @@ exports[` Password story renders snapshot 1`] = ` > @@ -306,7 +306,7 @@ exports[` Password story renders snapshot 1`] = ` @@ -398,6 +398,54 @@ exports[` Required story renders snapshot 1`] = ` `; +exports[` RequiredDisabled story renders snapshot 1`] = ` +
+
+
+ + + (Required) + +
+
+ +
+
+ This is a fieldnote for a required input field. +
+
+
+`; + exports[` ShowHint story renders snapshot 1`] = `
ShowHint story renders snapshot 1`] = ` > @@ -426,7 +474,7 @@ exports[` ShowHint story renders snapshot 1`] = `
@@ -565,7 +613,7 @@ exports[` WithAMaxLength story renders snapshot 1`] = ` > @@ -588,7 +636,7 @@ exports[` WithAMaxLength story renders snapshot 1`] = ` WithARecommendedLength story renders snapshot 1`] = ` > @@ -637,7 +685,7 @@ exports[` WithARecommendedLength story renders snapshot 1`] = ` WithBothMaxAndRecommendedLength story renders snapshot 1 > @@ -683,10 +731,10 @@ exports[` WithBothMaxAndRecommendedLength story renders snapshot 1 class="input-field__body input-field--has-fieldNote" > WithBothMaxAndRecommendedLength story renders snapshot 1 >
{required && showHint && ( - + (Required) )} {!required && showHint && ( - + (Optional) )}