-
Notifications
You must be signed in to change notification settings - Fork 882
[EuiComboBox] support append and prepend for group labels #7800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 8 commits
3a16ea1
2f418f6
83b5a5a
ebc2af3
fdd46c8
a100c8c
f5d49b7
3ef63b8
84f9327
c430c83
d0949dc
b852f70
e6f9356
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - Updated `EuiComboBox` to support output of `option.append` and `option.prepend` for options used as group labels with `isGroupLabel=true` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,14 +6,17 @@ | |
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import type { Meta, StoryObj } from '@storybook/react'; | ||
| import { action } from '@storybook/addon-actions'; | ||
|
|
||
| import { | ||
| enableFunctionToggleControls, | ||
| moveStorybookControlsToCategory, | ||
| } from '../../../../.storybook/utils'; | ||
| import { EuiFlexItem } from '../../flex'; | ||
| import { EuiSelectableOption } from '../selectable_option'; | ||
|
|
||
| import { EuiSelectableList, EuiSelectableListProps } from './selectable_list'; | ||
|
|
||
| const options: EuiSelectableOption[] = [ | ||
|
|
@@ -107,3 +110,34 @@ export const Playground: Story = { | |
| }, | ||
| }, | ||
| }; | ||
|
|
||
| export const Groups: Story = { | ||
| parameters: { | ||
| controls: { | ||
| include: ['options'], | ||
| }, | ||
| }, | ||
| args: { | ||
| options: [ | ||
| { label: 'Group 1', isGroupLabel: true }, | ||
| ...[...options].splice(0, 4), | ||
| { | ||
| label: 'Group 2', | ||
| isGroupLabel: true, | ||
| prepend: '#prepend ', | ||
|
mgadewoll marked this conversation as resolved.
Outdated
|
||
| append: ( | ||
| <EuiFlexItem css={{ alignItems: 'flex-end' }}>(append)</EuiFlexItem> | ||
|
Comment on lines
+134
to
+135
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm that's odd, the append nodes shouldn't need extra CSS from consumers to get them to align to the right 🤔 Is this only happening for group labels? We may need to add some extra CSS in EUI if so
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, currently this is "needed". The passed append/prepend is output as is. There is no further styling or layout handling added. (code here) If we only pass the flex item it'll grow but it's left aligned
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ahhh gotcha. I wonder if we should add more OOTB styling for this? Probably an out of scope question for this PR, I'll ponder it more later / during either the Emotion conversion for this component or the EuiComboBox<>Selectable work! |
||
| ), | ||
| }, | ||
| ...[...options].splice(4, options.length), | ||
| ], | ||
| activeOptionIndex: 0, | ||
| makeOptionId: (index) => `selectable_list_item-${index}`, | ||
| // ensuring that onOptionClick triggers an action as it's | ||
| // only called through setActiveOptionIndex callback | ||
| setActiveOptionIndex: (index, callback) => { | ||
| callback?.(); | ||
| action('setActiveOptionIndex')(index); | ||
| }, | ||
| }, | ||
| }; | ||

Uh oh!
There was an error while loading. Please reload this page.