-
+ @mouseleave="handleMouseleave">
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -568,7 +566,6 @@ export default {
data() {
return {
hovered: false,
- focused: false,
hasActions: false,
hasSubname: false,
displayActionsOnHoverFocus: false,
@@ -619,7 +616,7 @@ export default {
/**
* Handle link click
*
- * @param {PointerEvent} event - Native click event
+ * @param {MouseEvent|KeyboardEvent} event - Native click or keydown event
* @param {Function} [navigate] - VueRouter link's navigate if any
* @param {string} [routerLinkHref] - VueRouter link's href
*/
@@ -634,14 +631,11 @@ export default {
if (routerLinkHref) {
navigate?.(event)
event.preventDefault()
+ } else {
+ window.location = this.href
}
},
- handleMouseover() {
- this.showActions()
- this.hovered = true
- },
-
showActions() {
if (this.hasActions) {
this.displayActionsOnHoverFocus = true
@@ -654,15 +648,14 @@ export default {
},
/**
- * Show actions upon focus
+ * @param {FocusEvent} event UI event
*/
- handleFocus() {
- this.focused = true
- this.showActions()
- },
-
- handleBlur() {
- this.focused = false
+ handleBlur(event) {
+ // do not hide if focus is kept within
+ if (this.$refs['list-item'].contains(event.relatedTarget)) {
+ return
+ }
+ this.hideActions()
},
/**
@@ -675,20 +668,9 @@ export default {
this.hovered = false
},
- /**
- * This method checks if the root element of the component is focused and
- * if that's the case it focuses the actions button if available
- *
- * @param {Event} e the keydown event
- */
- handleTab(e) {
- if (this.focused && this.hasActions) {
- e.preventDefault()
- this.$refs.actions.$refs.menuButton.$el.focus()
- this.focused = false
- } else {
- this.displayActionsOnHoverFocus = false
- }
+ handleMouseover() {
+ this.showActions()
+ this.hovered = true
},
handleActionsUpdateOpen(e) {
@@ -723,14 +705,13 @@ export default {
width: 100%;
&--active,
- &:active,
&.active {
.list-item {
background-color: var(--color-primary-element);
- &:active,
&:hover,
- &:focus,
- &:focus-visible {
+ &:focus-within,
+ &:has(:focus-visible),
+ &:has(:active) {
background-color: var(--color-primary-element-hover);
}
}
@@ -748,7 +729,7 @@ export default {
// NcListItem
.list-item {
box-sizing: border-box;
- display: block;
+ display: flex;
position: relative;
flex: 0 0 auto;
justify-content: flex-start;
@@ -762,23 +743,29 @@ export default {
cursor: pointer;
transition: background-color var(--animation-quick) ease-in-out;
list-style: none;
- &:active,
&:hover,
- &:focus,
- &:focus-visible {
+ &:focus-within,
+ &:has(:active),
+ &:has(:focus-visible) {
background-color: var(--color-background-hover);
}
- &:focus-visible {
+ &:has(&__anchor:focus-visible) {
outline: 2px solid var(--color-main-text);
box-shadow: 0 0 0 4px var(--color-main-background);
}
- &-content__wrapper {
+ &__anchor {
display: flex;
+ flex: 1 0 auto;
align-items: center;
height: 48px;
+ // This is handled by the parent container
+ &:focus-visible {
+ outline: none;
+ }
+
&--compact {
height: 36px;