Skip to content

Commit

Permalink
[EuiButtonGroup] Fix initial focus when in a popover (#4288)
Browse files Browse the repository at this point in the history
By removing the `transition: all` on the `.euiButtonGroup__buttons` selector
- Also added an example to the compressed forms page.
  • Loading branch information
cchaos authored Nov 19, 2020
1 parent 2ec5242 commit 4248003
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 2 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
## [`master`](https://github.com/elastic/eui/tree/master)

No public interface changes since `30.4.1`.
**Bug fixes**

- Fixed initial focus of an `EuiButtonGroup` when first item in a popover ([#4288](https://github.com/elastic/eui/pull/4288))

## [`30.4.1`](https://github.com/elastic/eui/tree/v30.4.1)

Expand Down
26 changes: 26 additions & 0 deletions src-docs/src/views/form_compressed/form_compressed_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ import FormHelp from './form_horizontal_help';
const formHelpSource = require('!!raw-loader!./form_horizontal_help');
const formHelpHtml = renderToHtml(FormHelp);

import FormPopover from './form_compressed_popover';
const formPopoverSource = require('!!raw-loader!./form_compressed_popover');
const formPopoverHtml = renderToHtml(FormPopover);

import ComplexExample from './complex_example';
const ComplexExampleSource = require('!!raw-loader!./complex_example');
const ComplexExampleHtml = renderToHtml(ComplexExample);
Expand Down Expand Up @@ -185,6 +189,28 @@ export const FormCompressedExample = {
</EuiFormRow>`,
],
},
{
title: 'In a popover',
source: [
{
type: GuideSectionTypes.JS,
code: formPopoverSource,
},
{
type: GuideSectionTypes.HTML,
code: formPopoverHtml,
},
],
text: (
<Fragment>
<p>
Always use the compressed version of forms and elements when they
exist inside of a<Link to="/layout/popover">popover</Link>.
</p>
</Fragment>
),
demo: <FormPopover />,
},
{
title: 'Complex example',
source: [
Expand Down
80 changes: 80 additions & 0 deletions src-docs/src/views/form_compressed/form_compressed_popover.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import React, { useState } from 'react';

import {
EuiFieldText,
EuiFormRow,
EuiSelect,
EuiButton,
EuiPopover,
EuiButtonGroup,
} from '../../../../src/components';

export default () => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [granularityIdSelected, setGranularityIdSelected] = useState(
'granularityButton1'
);

const onButtonClick = () =>
setIsPopoverOpen((isPopoverOpen) => !isPopoverOpen);
const closePopover = () => setIsPopoverOpen(false);

const onGranularityChange = (optionId) => {
setGranularityIdSelected(optionId);
};

const button = (
<EuiButton iconType="arrowDown" iconSide="right" onClick={onButtonClick}>
Open form in popover
</EuiButton>
);

const granularityToggleButtons = [
{
id: 'granularityButton1',
label: 'Left',
},
{
id: 'granularityButton2',
label: 'Middle',
},
{
id: 'granularityButton3',
label: 'Right',
},
];

return (
<EuiPopover
button={button}
isOpen={isPopoverOpen}
closePopover={closePopover}>
<div style={{ width: 300 }}>
<EuiFormRow label="Button group" display="columnCompressed">
<EuiButtonGroup
legend="Granulariy of zoom levels"
options={granularityToggleButtons}
idSelected={granularityIdSelected}
onChange={onGranularityChange}
buttonSize="compressed"
isFullWidth
/>
</EuiFormRow>
<EuiFormRow label="Text field" display="columnCompressed">
<EuiFieldText name="first" compressed />
</EuiFormRow>

<EuiFormRow label={'Select'} display="columnCompressed">
<EuiSelect
options={[
{ value: 'option_one', text: 'Option one' },
{ value: 'option_two', text: 'Option two' },
{ value: 'option_three', text: 'Option three' },
]}
compressed
/>
</EuiFormRow>
</div>
</EuiPopover>
);
};
1 change: 0 additions & 1 deletion src/components/button/button_group/_button_group.scss
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
max-width: 100%;
display: flex;
overflow: hidden;
transition: all $euiAnimSpeedNormal ease-in-out;
}

.euiButtonGroup--isDisabled .euiButtonGroup__buttons {
Expand Down

0 comments on commit 4248003

Please sign in to comment.