From aa9804429086490f2d52cf2d67607bdf49e74bb3 Mon Sep 17 00:00:00 2001 From: Konstantin Schaper Date: Tue, 15 Jun 2021 10:11:59 +0200 Subject: [PATCH] Form elements that support react-hook-form can now be made read-only (#1696) The recently integrated form library react-hook-form does not submit disabled inputs, but a behaviour where interaction with an input is not possible and it is still submitted is necessary. This feature implements a readOnly property for all components that support react-hook-form. It is visually indistinguishable from a disabled input but will be submitted when the form is submitted. All form fields use disabled fieldset wrappers to accomplish this goal because react-hook-form only checks the disabled property on the input itself, not any ancestors, and the inputs are still correctly displayed as disabled. --- gradle/changelog/readonly_form_elements.yaml | 2 + .../src/__snapshots__/storyshots.test.ts.snap | 656 ++++++++++++------ .../src/forms/Checkbox.stories.tsx | 11 +- scm-ui/ui-components/src/forms/Checkbox.tsx | 7 +- .../src/forms/InputField.stories.tsx | 22 +- scm-ui/ui-components/src/forms/InputField.tsx | 6 +- .../ui-components/src/forms/Radio.stories.tsx | 4 + scm-ui/ui-components/src/forms/Radio.tsx | 11 +- .../src/forms/Select.stories.tsx | 22 + scm-ui/ui-components/src/forms/Select.tsx | 6 +- .../src/forms/Textarea.stories.tsx | 27 +- scm-ui/ui-components/src/forms/Textarea.tsx | 6 +- 12 files changed, 557 insertions(+), 223 deletions(-) create mode 100644 gradle/changelog/readonly_form_elements.yaml diff --git a/gradle/changelog/readonly_form_elements.yaml b/gradle/changelog/readonly_form_elements.yaml new file mode 100644 index 0000000000..23cea09f81 --- /dev/null +++ b/gradle/changelog/readonly_form_elements.yaml @@ -0,0 +1,2 @@ +- type: added + description: Form elements that support react-hook-form can now be made read-only ([#1696](https://github.com/scm-manager/scm-manager/pulls/1696)) diff --git a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap index 7e1a50c3ca..1b71cc893a 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -46451,7 +46451,7 @@ exports[`Storyshots Forms|AddKeyValueEntryToTableField Default 1`] = `
-
-
-
+
- +