Skip to content

Commit

Permalink
feat(combobox-web): select all button focus styling
Browse files Browse the repository at this point in the history
  • Loading branch information
rahmanunver authored and gjulivan committed Jan 12, 2024
1 parent 14b3dae commit 7aa5c1f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export function MultiSelection({
<SelectAllButton
value={isOptionsSelected}
id={`${options.inputId}-select-all-button`}
unfocused={highlightedIndex >= 0}
ariaLabel={a11yConfig.ariaLabels.selectAll}
onChange={() => {
if (isOptionsSelected === "all") {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
import { UseComboboxPropGetters } from "downshift/typings";
import { ReactElement, Fragment, createElement } from "react";
import { ThreeStateCheckBox, ThreeStateCheckBoxEnum } from "@mendix/widget-plugin-component-kit/ThreeStateCheckBox";
import classNames from "classnames";
import { UseComboboxPropGetters } from "downshift/typings";
import { Fragment, ReactElement, createElement } from "react";
import { CaptionContent } from "../../helpers/Association/AssociationSimpleCaptionsProvider";

interface SelectAllButtonProps extends Partial<UseComboboxPropGetters<string>> {
id?: string;
ariaLabel?: string;
value: ThreeStateCheckBoxEnum;
unfocused: boolean;
onChange?: () => void;
}

export function SelectAllButton({ id, ariaLabel, value, onChange }: SelectAllButtonProps): ReactElement {
export function SelectAllButton({ id, ariaLabel, value, unfocused, onChange }: SelectAllButtonProps): ReactElement {
return (
<Fragment>
<span className="widget-combobox-icon-container">
<span
className={classNames(
"widget-combobox-menu-header-select-all-button",
"widget-combobox-icon-container",
{ unfocused }
)}
>
<ThreeStateCheckBox value={value} id={id} onChange={onChange} />
</span>
{ariaLabel ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ function useComboboxProps(
})
};
case useCombobox.stateChangeTypes.InputBlur:
return state;
return { ...state, highlightedIndex: -1 };
default:
return changes;
}
Expand Down
13 changes: 12 additions & 1 deletion packages/pluggableWidgets/combobox-web/src/ui/Combobox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,22 @@ $menu-outer-padding: 10px;
background-color: $highlighted-index;
}

&:has(input[type="checkbox"]:hover) + .widget-combobox-menu-list input[type="checkbox"]:after {
&:has(input[type="checkbox"]:hover, :focus, :focus-within)
+ .widget-combobox-menu-list
input[type="checkbox"]:after {
content: "";
border-color: $hover-color;
}

&-select-all-button {
&.unfocused {
.three-state-checkbox {
outline: none;
}
}
}
}

&-footer {
border-top: 1px solid $gray-primary;
padding: $menu-outer-padding;
Expand Down

0 comments on commit 7aa5c1f

Please sign in to comment.