From 005ca83799cb2255eafe1b2d902d813e82888057 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Tue, 10 Mar 2020 10:51:15 +0100 Subject: [PATCH] Fix drop down selection --- CHANGELOG.md | 1 + .../src/__snapshots__/storyshots.test.ts.snap | 60 +++++++++++++++++++ .../src/forms/DropDown.stories.tsx | 28 +++++++++ scm-ui/ui-components/src/forms/DropDown.tsx | 11 +--- 4 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 scm-ui/ui-components/src/forms/DropDown.stories.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 15720de4e4..4a79f98df5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Modification for mercurial repositories with enabled XSRF protection - Does not throw NullPointerException when merge fails without normal merge conflicts - Keep file attributes on modification +- Drop Down Component works again with translations ### Removed - Enunciate rest documentation 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 790c2cdc94..0df9e311c8 100644 --- a/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap +++ b/scm-ui/ui-components/src/__snapshots__/storyshots.test.ts.snap @@ -32263,6 +32263,66 @@ exports[`Storyshots Forms|Checkbox Disabled 1`] = ` `; +exports[`Storyshots Forms|DropDown Default 1`] = ` +
+ +
+`; + +exports[`Storyshots Forms|DropDown With Translation 1`] = ` +
+ +
+`; + exports[`Storyshots Forms|Radio Default 1`] = `
( + { + // nothing to do + }} + /> + )) + .add("With Translation", () => ( + { + // nothing to do + }} + /> + )); diff --git a/scm-ui/ui-components/src/forms/DropDown.tsx b/scm-ui/ui-components/src/forms/DropDown.tsx index dac9af2880..9b495a9c1d 100644 --- a/scm-ui/ui-components/src/forms/DropDown.tsx +++ b/scm-ui/ui-components/src/forms/DropDown.tsx @@ -6,25 +6,20 @@ type Props = { optionValues?: string[]; optionSelected: (p: string) => void; preselectedOption?: string; - className: string; + className?: string; disabled?: boolean; }; class DropDown extends React.Component { render() { const { options, optionValues, preselectedOption, className, disabled } = this.props; - - if (preselectedOption && !options.includes(preselectedOption)) { - options.unshift(preselectedOption); - } - return (