diff --git a/CHANGELOG.md b/CHANGELOG.md index 758bbaf1e67..723587f9ee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ ## [`master`](https://github.com/elastic/eui/tree/master) - Added `eql` glyph in `EuiIcon` ([#4110](https://github.com/elastic/eui/pull/4110)) -- Added `testenv` mock for `htmlIdGenerator` ([#4212](https://github.com/elastic/eui/pull/4212)) +- Added `testenv` mock for `htmlIdGenerator` ([#4212](https://github.com/elastic/eui/pull/4212)) +- Added several Sass mixins for handling of unified focus/hover states ([#4242](https://github.com/elastic/eui/pull/4242)) **Theme: Amsterdam** +- Unify focus states by leaning into `outline` and restricting to keyboard navigation ([#4242](https://github.com/elastic/eui/pull/4242)) - Removed faux border from `EuiAvatar` ([#4255](https://github.com/elastic/eui/pull/4255)) ## [`30.3.0`](https://github.com/elastic/eui/tree/v30.3.0) diff --git a/src-docs/src/views/button/button_ghost.js b/src-docs/src/views/button/button_ghost.js index d33455bfea2..95413ec09ab 100644 --- a/src-docs/src/views/button/button_ghost.js +++ b/src-docs/src/views/button/button_ghost.js @@ -17,7 +17,10 @@ export default () => { }; return ( - + {}}> diff --git a/src-docs/src/views/icon/icon_colors.js b/src-docs/src/views/icon/icon_colors.js index cdca18c7af8..13aeee59bc5 100644 --- a/src-docs/src/views/icon/icon_colors.js +++ b/src-docs/src/views/icon/icon_colors.js @@ -47,6 +47,7 @@ export default () => ( key={iconColor} style={{ width: '340px' }}> diff --git a/src/components/breadcrumbs/_breadcrumbs.scss b/src/components/breadcrumbs/_breadcrumbs.scss index 58da52538d9..f8a574f8478 100644 --- a/src/components/breadcrumbs/_breadcrumbs.scss +++ b/src/components/breadcrumbs/_breadcrumbs.scss @@ -47,7 +47,6 @@ .euiBreadcrumbs--truncate { white-space: nowrap; flex-wrap: nowrap; - overflow: hidden; .euiBreadcrumb:not(.euiBreadcrumb--collapsed) { max-width: $euiBreadcrumbTruncateWidth; diff --git a/src/components/collapsible_nav/_collapsible_nav.scss b/src/components/collapsible_nav/_collapsible_nav.scss index 4e2536bf4d5..d63860af27b 100644 --- a/src/components/collapsible_nav/_collapsible_nav.scss +++ b/src/components/collapsible_nav/_collapsible_nav.scss @@ -24,12 +24,8 @@ &:focus { @include euiFocusRing; - } - - &, - &:focus { // Override default `EuiButtonEmpty` :focus background to ensure better contrast - background: $euiColorEmptyShade; + background: $euiColorEmptyShade !important; // sass-lint:disable-line no-important } } diff --git a/src/components/color_picker/color_stops/_color_stops.scss b/src/components/color_picker/color_stops/_color_stops.scss index d43e4223aa9..dc3e82423bc 100644 --- a/src/components/color_picker/color_stops/_color_stops.scss +++ b/src/components/color_picker/color_stops/_color_stops.scss @@ -57,7 +57,7 @@ height: 100%; // Background color can potentially have opacity - // Pseudo element placed below the thumb to prevent the track from showing through + // Pseudo element placed below the thumb to prevent the track from showing through &:before { content: ''; display: block; diff --git a/src/components/combo_box/combo_box_input/_combo_box_input.scss b/src/components/combo_box/combo_box_input/_combo_box_input.scss index 2d75fc78757..1781b0f5749 100644 --- a/src/components/combo_box/combo_box_input/_combo_box_input.scss +++ b/src/components/combo_box/combo_box_input/_combo_box_input.scss @@ -2,11 +2,10 @@ max-width: 100%; // Ensure that no input states are visible on the hidden input - input[aria-hidden='true'] { + input { // sass-lint:disable-block no-important border: none !important; box-shadow: none !important; outline: none !important; } - } diff --git a/src/components/combo_box/combo_box_options_list/_combo_box_option.scss b/src/components/combo_box/combo_box_options_list/_combo_box_option.scss index e3ac2e4e4c6..9f7f68ce90f 100644 --- a/src/components/combo_box/combo_box_options_list/_combo_box_option.scss +++ b/src/components/combo_box/combo_box_options_list/_combo_box_option.scss @@ -14,7 +14,7 @@ &.euiComboBoxOption-isFocused { cursor: pointer; - color: $euiColorPrimary; + color: $euiColorPrimaryText; background-color: $euiFocusBackgroundColor; } diff --git a/src/components/context_menu/_context_menu_item.scss b/src/components/context_menu/_context_menu_item.scss index 894fe91468c..453c4f1cdab 100644 --- a/src/components/context_menu/_context_menu_item.scss +++ b/src/components/context_menu/_context_menu_item.scss @@ -4,6 +4,7 @@ width: 100%; text-align: left; color: $euiTextColor; + outline-offset: -$euiFocusRingSize; &:hover, &:focus { diff --git a/src/components/context_menu/_context_menu_panel.scss b/src/components/context_menu/_context_menu_panel.scss index ebd3cc169d1..d6999edb8f6 100644 --- a/src/components/context_menu/_context_menu_panel.scss +++ b/src/components/context_menu/_context_menu_panel.scss @@ -1,6 +1,7 @@ .euiContextMenuPanel { width: 100%; visibility: visible; + outline-offset: -$euiFocusRingSize; &.euiContextMenuPanel-txInLeft { pointer-events: none; @@ -36,9 +37,9 @@ .euiContextMenuPanelTitle { @include euiPopoverTitle; padding: $euiSizeM; - width: 100%; text-align: left; + outline-offset: -$euiFocusRingSize; &:enabled:hover, &:enabled:focus { diff --git a/src/components/datagrid/_data_grid_column_sorting.scss b/src/components/datagrid/_data_grid_column_sorting.scss index 30a9983e605..1bbe555bf3b 100644 --- a/src/components/datagrid/_data_grid_column_sorting.scss +++ b/src/components/datagrid/_data_grid_column_sorting.scss @@ -26,18 +26,17 @@ .euiDataGridColumnSorting__fieldList { @include euiYScrollWithShadows; + padding-top: $euiSizeXS; + padding-bottom: $euiSizeXS; max-height: 300px; } .euiDataGridColumnSorting__field { + @include euiInteractiveStates; display: block; - padding: $euiSizeXS; + padding: $euiSizeXS $euiSizeS; width: 100%; - - &:focus { - background: $euiFocusBackgroundColor; - text-decoration: underline; - } + outline-offset: -$euiFocusRingSize; } .euiDataGridColumnSorting__orderButtons { diff --git a/src/components/datagrid/_data_grid_header_row.scss b/src/components/datagrid/_data_grid_header_row.scss index e8f34595559..2747e40ac72 100644 --- a/src/components/datagrid/_data_grid_header_row.scss +++ b/src/components/datagrid/_data_grid_header_row.scss @@ -32,6 +32,7 @@ &:focus { @include euiDataGridCellFocus; + border-top: none; } // We only truncate if the cell is not a control column. @@ -39,6 +40,7 @@ &:focus-within { @include euiDataGridCellFocus; + border-top: none; } .euiDataGridHeaderCell__button { @@ -48,6 +50,7 @@ display: flex; text-align: left; font-weight: $euiFontWeightBold; + outline: none; } .euiDataGridHeaderCell__content { diff --git a/src/components/datagrid/_mixins.scss b/src/components/datagrid/_mixins.scss index e5d1727ecb9..32deed7e4f4 100644 --- a/src/components/datagrid/_mixins.scss +++ b/src/components/datagrid/_mixins.scss @@ -55,6 +55,7 @@ $euiDataGridStyles: ( box-shadow: 0 0 0 2px $euiFocusRingColor; border-radius: 1px; z-index: 2; // Needed so it sits above potential striping in the next row + outline: none; // Remove outline as we're handling it manually } @mixin euiDataGridRowCell { diff --git a/src/components/datagrid/column_sorting.tsx b/src/components/datagrid/column_sorting.tsx index 8e419b38403..cbece737c9f 100644 --- a/src/components/datagrid/column_sorting.tsx +++ b/src/components/datagrid/column_sorting.tsx @@ -211,7 +211,7 @@ export const useColumnSorting = ( isOpen={avilableColumnsisOpen} closePopover={() => setAvailableColumnsIsOpen(false)} anchorPosition="downLeft" - panelPaddingSize="s" + panelPaddingSize="none" button={ .euiIcon { @include euiFormControlSideBorderRadius($euiFormControlBorderRadius, $side: 'right', $internal: true); } diff --git a/src/themes/eui-amsterdam/overrides/_form_controls.scss b/src/themes/eui-amsterdam/overrides/_form_controls.scss new file mode 100644 index 00000000000..27780109657 --- /dev/null +++ b/src/themes/eui-amsterdam/overrides/_form_controls.scss @@ -0,0 +1,19 @@ +.euiRadio .euiRadio__input { + &:focus { + @include euiCustomControlFocused('.euiRadio__circle'); + } +} + +.euiCheckbox .euiCheckbox__input { + &:focus { + @include euiCustomControlFocused('.euiCheckbox__square'); + } +} + +.euiSwitch .euiSwitch__button:focus { + @include euiFocusRing(null, 'outer'); + + .euiSwitch__track { + outline: none; + } +} diff --git a/src/themes/eui-amsterdam/overrides/_header.scss b/src/themes/eui-amsterdam/overrides/_header.scss index 9f65c9a03b6..31976f5af01 100644 --- a/src/themes/eui-amsterdam/overrides/_header.scss +++ b/src/themes/eui-amsterdam/overrides/_header.scss @@ -51,6 +51,10 @@ padding: $euiSizeXS $euiSize; clip-path: polygon(0 0, calc(100% - #{$euiSizeS}) 0, 100% 50%, calc(100% - #{$euiSizeS}) 100%, 0 100%, $euiSizeS 50%); + &:focus { + @include euiFocusRing(null, 'inner'); + } + // If it's a link the easiest way to detect is via our .euiLink class since it can accept either href or onClick // Also helps to add specificity for overriding hover state &.euiBreadcrumb--collapsed, diff --git a/src/themes/eui-amsterdam/overrides/_index.scss b/src/themes/eui-amsterdam/overrides/_index.scss index 6b40439fcd8..df44dc2513a 100644 --- a/src/themes/eui-amsterdam/overrides/_index.scss +++ b/src/themes/eui-amsterdam/overrides/_index.scss @@ -6,6 +6,9 @@ @import 'code'; @import 'context_menu'; @import 'filter_group'; +@import 'form_control_layout'; +@import 'form_control_layout_delimited'; +@import 'form_controls'; @import 'header'; @import 'image'; @import 'mark'; @@ -15,5 +18,3 @@ @import 'progress'; @import 'text'; @import 'toast'; -@import 'form_control_layout'; -@import 'form_control_layout_delimited'; diff --git a/src/themes/eui/eui_colors_dark.scss b/src/themes/eui/eui_colors_dark.scss index 02cb1b51b48..eb7a1ca7198 100644 --- a/src/themes/eui/eui_colors_dark.scss +++ b/src/themes/eui/eui_colors_dark.scss @@ -27,7 +27,6 @@ $euiColorFullShade: #FFF; // Variations from core $euiTextColor: #DFE5EF; $euiLinkColor: $euiColorPrimary; -$euiFocusBackgroundColor: #232635; $euiShadowColor: #000; $euiShadowColorLarge: #000; $euiPageBackgroundColor: shade($euiColorLightestShade, 30%);