From 15e340b321f5ad9bfcc55706152c1b25e78ad97c Mon Sep 17 00:00:00 2001 From: Carina <47381367+ssb-cgn@users.noreply.github.com> Date: Tue, 22 Feb 2022 15:07:58 +0100 Subject: [PATCH] Mimir 1082 uu dropdown (#363) * MIMIR-1082:First version to get dropdown more UU friendly * MIMIR-1082:Fix styling list elements * MIMIR-1082:Fixed keynavigatin in list and scroll on page TODO:Fix keynavigation in safari * MIMIR-1082:Fixed onKeyDown for Button on safari Had to set focus to button * MIMIR-1082:Better voice over support * MIMIR-1084:Updated tests and fixed some stuff * MIMIR-1082:Some small changes * MIMIR-1082:Updated snapshot and documentation * MIMIR-1082:Small fixes * MIMIR-1082:More small fixes * MIMIR-1082:Som cleanup on code for header * MIMIR-1082:Fixes styling hover and focus, and fixes disabled items * MIMIR-1082:Fixes tests and updatet bundle.css --- lib/bundle.css | 59 +++---- src/components/Dropdown/README.md | 54 +++++-- .../__snapshots__/dropdown.test.jsx.snap | 14 +- src/components/Dropdown/_dropdown.scss | 24 ++- src/components/Dropdown/dropdown.test.jsx | 4 +- src/components/Dropdown/index.jsx | 150 +++++++++++------- src/style/_global-styles.scss | 12 ++ 7 files changed, 180 insertions(+), 137 deletions(-) diff --git a/lib/bundle.css b/lib/bundle.css index 67d9dc57..2caa2f59 100644 --- a/lib/bundle.css +++ b/lib/bundle.css @@ -46,6 +46,18 @@ a { margin: 0 !important; } +.sr-only { + position: absolute; + width: 1px; + height: 1px; + padding: 0; + margin: -1px; + overflow: hidden; + clip: rect(0, 0, 0, 0); + white-space: nowrap; + border-width: 0; +} + .ssb-accordion { display: grid; width: 100%; @@ -671,28 +683,15 @@ a { min-width: 230px; position: relative; } -.ssb-dropdown label { +.ssb-dropdown label, .ssb-dropdown #dropdown-label { font-size: 14px; line-height: normal; margin-bottom: 5px; } .ssb-dropdown .dropdown-interactive-area { - background-color: transparent; - border: none; - color: inherit; - cursor: pointer; - font-family: inherit; - font-size: inherit; - line-height: inherit; - padding: 0; - text-align: left; cursor: pointer; position: relative; } -.ssb-dropdown .dropdown-interactive-area:focus { - outline: #9272fc solid 2px; - outline-offset: 2px; -} .ssb-dropdown .dropdown-interactive-area button { background-color: transparent; border: none; @@ -713,9 +712,9 @@ a { padding: 4px 44px 4px 12px; text-overflow: ellipsis; } -.ssb-dropdown .dropdown-interactive-area button:focus { - outline: #9272fc solid 2px; - outline-offset: 2px; +.ssb-dropdown .dropdown-interactive-area button:hover, .ssb-dropdown .dropdown-interactive-area button:focus { + border: 1px solid #00824d; + outline: 1px solid #00824d; } .ssb-dropdown .dropdown-interactive-area .dd-icon { color: #00824d; @@ -739,12 +738,9 @@ a { .ssb-dropdown .dropdown-interactive-area input::placeholder { color: #162327; } -.ssb-dropdown .dropdown-interactive-area input:hover { - border: 1px solid #00824d; -} -.ssb-dropdown .dropdown-interactive-area input:focus, .ssb-dropdown .dropdown-interactive-area input.focused { +.ssb-dropdown .dropdown-interactive-area input:hover, .ssb-dropdown .dropdown-interactive-area input:focus { border: 1px solid #00824d; - outline: #00824d auto 1px; + outline: 1px solid #00824d; } .ssb-dropdown.error input, .ssb-dropdown.error button.opener { border: 1px solid #ed5935; @@ -771,15 +767,6 @@ a { width: 100%; } .ssb-dropdown .list-of-options .option-list-element { - background-color: transparent; - border: none; - color: inherit; - cursor: pointer; - font-family: inherit; - font-size: inherit; - line-height: inherit; - padding: 0; - text-align: left; font-family: "Roboto", sans-serif !important; font-stretch: normal; font-weight: normal; @@ -793,24 +780,22 @@ a { padding: 12px; text-overflow: ellipsis; transition: all 0.18s; + box-sizing: border-box; width: 100%; } -.ssb-dropdown .list-of-options .option-list-element:focus { - outline: #9272fc solid 2px; - outline-offset: 2px; -} .ssb-dropdown .list-of-options .option-list-element:hover, .ssb-dropdown .list-of-options .option-list-element:focus, .ssb-dropdown .list-of-options .option-list-element.active { background: #274247; color: #fff; z-index: 2; } -.ssb-dropdown .list-of-options .option-list-element:disabled { +.ssb-dropdown .list-of-options .option-list-element.disabled { background: #fff; color: #c3dcdc; cursor: not-allowed; font-weight: normal; + pointer-events: none; } -.ssb-dropdown .list-of-options .option-list-element:disabled:hover, .ssb-dropdown .list-of-options .option-list-element:disabled:focus { +.ssb-dropdown .list-of-options .option-list-element.disabled:hover, .ssb-dropdown .list-of-options .option-list-element.disabled:focus { text-decoration: none; background: none; } diff --git a/src/components/Dropdown/README.md b/src/components/Dropdown/README.md index 6dfce5ff..8b92b3cf 100644 --- a/src/components/Dropdown/README.md +++ b/src/components/Dropdown/README.md @@ -25,25 +25,43 @@ Dropdown ### Usage -#### HTML +#### HTML standard dropdown This component needs some javascript functionality to work. ```html -
- - + +``` + +#### HTML dropdown with search (combobox with autocomplete) +This component needs some javascript functionality to work. +```html + ``` @@ -78,6 +96,7 @@ Available props: | Name | Type | Description | | ---------- | ------------- | ----- | +| id | string | Optional id | | className | string | Optional container class| | error | bool | show error message if true | | errorMessage | string | Renders an error message underneath input field | @@ -90,3 +109,4 @@ Available props: | searchable | bool | If true, dropdown is searchable | | selectedItem | object | Selected element in dropdown | | tabIndex | number | Tab index for focus | +| ariaLabel | string | Defines a string value that labels input or span to button element, use if not visible header | diff --git a/src/components/Dropdown/__snapshots__/dropdown.test.jsx.snap b/src/components/Dropdown/__snapshots__/dropdown.test.jsx.snap index deee809d..679b9360 100644 --- a/src/components/Dropdown/__snapshots__/dropdown.test.jsx.snap +++ b/src/components/Dropdown/__snapshots__/dropdown.test.jsx.snap @@ -3,22 +3,22 @@ exports[`Dropdown component Matches the snapshot 1`] = `