Skip to content

Commit

Permalink
fix(core/group): fix focus visual and behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
nuke-ellington committed Aug 9, 2022
1 parent c4db125 commit ecaa4ba
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 11 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ export namespace Components {
"label": string;
}
interface CwGroupItem {
/**
* The elements tabindex attribute will get set accordingly. If true tabindex will be 0, -1 otherwise.
*/
"focusable": boolean;
/**
* Group item icon
*/
Expand Down Expand Up @@ -2077,6 +2081,10 @@ declare namespace LocalJSX {
"label"?: string;
}
interface CwGroupItem {
/**
* The elements tabindex attribute will get set accordingly. If true tabindex will be 0, -1 otherwise.
*/
"focusable"?: boolean;
/**
* Group item icon
*/
Expand Down
9 changes: 7 additions & 2 deletions packages/core/src/components/group-item/group-item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
align-items: center;
justify-content: space-between;
padding: $small-space $large-space $small-space 2.5rem;
border: var(--theme-primary-bdr-1);
border-top-width: 0;
position: relative;
margin-top: 0.0625rem;
border: 1px solid var(--theme-group-item--border-color);
outline: none;

background-color: var(--theme-group-item--background);

Expand Down Expand Up @@ -76,4 +77,8 @@
background-color: var(--theme-color-input-focus);
}
}

@include focus-visible {
border-color: var(--focus--border-color) !important;
}
}
8 changes: 7 additions & 1 deletion packages/core/src/components/group-item/group-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ export class GroupItem {
*/
@Prop() selected: boolean;

/**
* The elements tabindex attribute will get set accordingly.
* If true tabindex will be 0, -1 otherwise.
*/
@Prop() focusable = true;

/**
* Selection changed
*/
Expand All @@ -61,7 +67,7 @@ export class GroupItem {
'selected': this.selected && !this.suppressSelection,
'suppress-selection': this.suppressSelection,
}}
tabindex="0"
tabindex={this.focusable ? 0 : -1}
>
<div class="group-entry-selection-indicator"></div>
{this.icon ? <cw-icon size="16" name={this.icon}></cw-icon> : null}
Expand Down
15 changes: 8 additions & 7 deletions packages/core/src/components/group/group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
position: relative;
max-width: 19.75rem;
border-color: var(--theme-group-item--border-color);
border-radius: var(--theme-group--border-radius);

@include focus-visible {
border-color: var(--theme-focus--border-color);
border-radius: var(--theme-group--border-radius--focus);
}

.group-header-context-button {
display: block;
Expand All @@ -44,6 +38,7 @@
border: var(--theme-std-bdr-1);
display: flex;
background-color: var(--theme-group-item--background);
border: 1px solid var(--theme-group-item--border-color);
color: var(--theme-group-header--color);

cursor: pointer;
Expand All @@ -57,6 +52,12 @@
background-color: var(--theme-group-item--background--active);
border-color: var(--theme-group-item--border-color--active);
}

@include focus-visible {
border-color: var(--focus--border-color);
border-radius: var(--theme-group--border-radius--focus);
outline: none;
}
}

.group-header-clickable {
Expand Down Expand Up @@ -110,7 +111,7 @@

height: 1.25rem;
font-size: 0.875rem;
color: var(--theme-group-subheader--color)
color: var(--theme-group-subheader--color);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/group/group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class Group {
<slot></slot>
</div>
<div class="d-none">
<cw-group-item class="footer last" suppressSelection={true} tabindex="-1">
<cw-group-item class="footer last" suppressSelection={true} focusable={false}>
<slot name="footer"></slot>
</cw-group-item>
</div>
Expand Down

0 comments on commit ecaa4ba

Please sign in to comment.