diff --git a/src/components/selectable/selectable_list/_selectable_list.scss b/src/components/selectable/selectable_list/_selectable_list.scss index 6e314a96eec..a48d32679e7 100644 --- a/src/components/selectable/selectable_list/_selectable_list.scss +++ b/src/components/selectable/selectable_list/_selectable_list.scss @@ -1,10 +1,12 @@ -// Expand height of list via flex box .euiSelectableList { - &:focus-within { - @include euiFocusRing; + // NOTE: This is currently only visible on supported browsers (all except FF) + // which is (unfortunately) better than always displaying the focus ring to mouse users + &:has(:focus-visible) { + @include euiFocusRing(null, $euiFocusRingSize / 2, false); } } +// Expand height of list via flex box .euiSelectableList-fullHeight { flex-grow: 1; } @@ -18,6 +20,11 @@ .euiSelectableList__list { @include euiOverflowShadow; @include euiScrollBar; + + &:focus, + & > ul:focus { + outline: none; // Focus outline handled by parent .euiSelectableList + } } .euiSelectableList__groupLabel { diff --git a/src/themes/amsterdam/global_styling/mixins/_states.scss b/src/themes/amsterdam/global_styling/mixins/_states.scss index 27698e2ab06..81279d81b98 100644 --- a/src/themes/amsterdam/global_styling/mixins/_states.scss +++ b/src/themes/amsterdam/global_styling/mixins/_states.scss @@ -3,22 +3,31 @@ // This re-uses the same faux focus ring mixin, but adjusts the outline instead // @param {size} Old param from default theme that won't be used, so it should always be `null` // @param {offset} Accepts a specific number or 'inner' or 'outer' to adjust outline position -@mixin euiFocusRing($size: null, $offset: false) { +// @param {includeFocusVisible} Allows turning off :not:focus-visible selector (which can interfere with some manual usages) +@mixin euiFocusRing($size: null, $offset: false, $focusVisibleSelectors: true) { // Safari & Firefox outline: $euiFocusRingSize solid currentColor; - // Chrome - &:focus-visible { - outline-style: auto; - } + @if ($focusVisibleSelectors) { + // Chrome + &:focus-visible { + outline-style: auto; + } - &:not(:focus-visible) { - outline: none; + &:not(:focus-visible) { + outline: none; + } + } @else { + outline-style: auto; } // Adjusting position with offset @if (type-of($offset) == number) { - outline-offset: #{$offset}px; + @if (unitless($offset)) { + outline-offset: #{$offset}px; + } @else { + outline-offset: #{$offset}; + } } @else if ($offset == 'inner') { outline-offset: -$euiFocusRingSize; } @else if ($offset == 'outer') { diff --git a/upcoming_changelogs/6637.md b/upcoming_changelogs/6637.md new file mode 100644 index 00000000000..8698eac8be7 --- /dev/null +++ b/upcoming_changelogs/6637.md @@ -0,0 +1,3 @@ +**Bug fixes** + +- Fixed visual listbox focus ring bug on non-searchable `EuiSelectable`s