Skip to content

Commit

Permalink
chore: fix highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
anubra266 committed Jan 5, 2025
1 parent 42c2828 commit 225c995
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 6 additions & 5 deletions packages/machines/cascader/src/cascader.connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,25 +361,26 @@ export function connect<T extends PropTypes, V = any>(
id: dom.getItemId(state.context, itemState.value),
dir: state.context.dir,
role: "treeitem",
"data-index-path": props.indexPath.join(","),
"aria-haspopup": itemState.isBranch ? "menu" : undefined,
"aria-expanded": itemState.isBranch ? itemState.highlighted : false,
"aria-controls": itemState.isBranch ? dom.getListId(state.context, itemState.value) : undefined,
"data-value": itemState.value,
"aria-owns": itemState.isBranch ? dom.getListId(state.context, itemState.value) : undefined,
"aria-selected": itemState.selected,
"aria-disabled": ariaAttr(itemState.disabled),
"data-value": itemState.value,
"data-state": itemState.selected ? "checked" : "unchecked",
"data-highlighted": dataAttr(itemState.highlighted),
"data-disabled": dataAttr(itemState.disabled),
"aria-disabled": ariaAttr(itemState.disabled),
"data-selected": dataAttr(itemState.selected),
"data-type": itemState.isBranch ? "branch" : "leaf",
"data-index-path": props.indexPath.join(","),
onDoubleClick() {
if (itemState.disabled) return
send("CLOSE")
},
onPointerMove(event) {
if (itemState.disabled || event.pointerType !== "mouse") return
if (highlightedValue === itemState.value) return
// We only want to highlight items that have children (mouse only)
if (!itemState.isBranch) return
send({ type: "ITEM.POINTER_MOVE", indexPath })
},
onClick(event) {
Expand Down
9 changes: 5 additions & 4 deletions shared/src/css/cascader.css
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@
cursor: not-allowed;
}

[data-scope="cascader"][data-part="item"]:not([data-disabled]):not([data-highlighted]):hover {
background: rgba(107, 107, 110, 0.105);
}

[data-scope="cascader"][data-part="item"][data-highlighted] {
background: rgb(0, 0, 195);
color: white;
}

[data-scope="cascader"][data-part="item"][data-highlighted][data-type="leaf"] {
background: rgba(107, 107, 110, 0.105);
color: inherit;
}

[data-scope="cascader"][data-part="item-text"] {
flex: 1;
width: 100%;
Expand Down

0 comments on commit 225c995

Please sign in to comment.