Skip to content

Commit

Permalink
fix(Multiselect): remove focus when MultiSelect is open (#16259)
Browse files Browse the repository at this point in the history
* fix(Multiselect): remove focus when MultiSelect is open

* fix(Multiselect): add focus when item is selected, add with layer story

---------

Co-authored-by: Kritvi <158570656+Kritvi-bhatia17@users.noreply.github.com>
  • Loading branch information
tw15egan and Kritvi-bhatia17 committed May 1, 2024
1 parent 9d4ce7e commit b348878
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/

import React from 'react';

import { WithLayer } from '../../../.storybook/templates/WithLayer';
import {
FluidMultiSelect,
FluidMultiSelectSkeleton,
Expand Down Expand Up @@ -82,6 +84,38 @@ export const Default = () => (
</div>
);

export const Filterable = () => (
<div style={{ width: '400px' }}>
<FluidMultiSelect
isFilterable
onChange={() => {}}
initialSelectedItem={items[2]}
id="default"
titleText="Label"
label="Choose an option"
items={items}
itemToString={(item) => (item ? item.text : '')}
/>
</div>
);

export const _FilterableWithLayer = () => (
<WithLayer>
{(layer) => (
<div style={{ width: 300 }}>
<FluidMultiSelect
isFilterable
id={`carbon-multiselect-example-${layer}`}
titleText="Multiselect title"
items={items}
itemToString={(item) => (item ? item.text : '')}
selectionFeedback="top-after-reopen"
/>
</div>
)}
</WithLayer>
);

export const Condensed = () => (
<div style={{ width: '400px' }}>
<FluidMultiSelect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,13 @@

.#{$prefix}--multi-select--filterable--input-focused,
.#{$prefix}--multi-select
.#{$prefix}--list-box__field--wrapper--input-focused {
.#{$prefix}--list-box__field--wrapper--input-focused:has(
button[aria-expanded='false']
),
.#{$prefix}--multi-select.#{$prefix}--multi-select--selected
.#{$prefix}--list-box__field--wrapper--input-focused:has(
button[aria-expanded='true']
) {
@include focus-outline('outline');
}

Expand Down

0 comments on commit b348878

Please sign in to comment.