From 190d2660c52516e7f2b1b258a3baa22590a76dec Mon Sep 17 00:00:00 2001 From: Michal Zajac <50200782+Michal99Zajac@users.noreply.github.com> Date: Fri, 18 Feb 2022 09:53:58 +0100 Subject: [PATCH] (SingleSelectField) Dont allow to select option when it is disabled (#1870) * fix(SingleSelectField): dont allow to select an option when it is disabled * feat(storybook): add story to the SingleSelectField * fix(storybook): update snapshot --- .../SingleSelectField/SingleSelectField.tsx | 5 ++ .../__snapshots__/Stories.test.ts.snap | 68 +++++++++++++++++++ .../stories/components/SingleSelectField.tsx | 10 +++ 3 files changed, 83 insertions(+) diff --git a/src/components/SingleSelectField/SingleSelectField.tsx b/src/components/SingleSelectField/SingleSelectField.tsx index 7b3082b00..fa2a051d8 100644 --- a/src/components/SingleSelectField/SingleSelectField.tsx +++ b/src/components/SingleSelectField/SingleSelectField.tsx @@ -10,6 +10,7 @@ import { import { SelectProps } from "@material-ui/core/Select"; import { makeStyles } from "@saleor/macaw-ui"; import classNames from "classnames"; +import clsx from "clsx"; import React from "react"; import { FormattedMessage } from "react-intl"; @@ -31,6 +32,9 @@ const useStyles = makeStyles( }, paper: { maxHeight: `calc(${singleSelectFieldItemHeight}px * 10 + ${singleSelectFieldItemHeight}px * 0.5)` + }, + disabledMenuItem: { + pointerEvents: "none" } }), { name: "SingleSelectField" } @@ -127,6 +131,7 @@ export const SingleSelectField: React.FC = props => { choices.map(choice => ( `; +exports[`Storyshots Generics / SingleSelectField with disabled options 1`] = ` +
+
+
+
+
+
+
+
+`; + exports[`Storyshots Generics / SingleSelectField with error hint 1`] = `
+ )) + .add("with disabled options", () => ( + ));