diff --git a/src-docs/src/views/popover/input_popover.tsx b/src-docs/src/views/popover/input_popover.tsx index 4536c765698..1e87b9ee1a3 100644 --- a/src-docs/src/views/popover/input_popover.tsx +++ b/src-docs/src/views/popover/input_popover.tsx @@ -1,43 +1,33 @@ import React, { useState } from 'react'; -import { EuiInputPopover, EuiFieldText, EuiSpacer } from '../../../../src'; +import { + EuiInputPopover, + EuiInputPopoverProps, + EuiFieldText, + EuiTextArea, + EuiButtonGroup, + EuiFormRow, + EuiSpacer, +} from '../../../../src'; export default () => { - const [inputWidth, setInputWidth] = useState(200); const [isPopoverOpen, setIsPopoverOpen] = useState(false); - const [isPopoverOpenTwo, setIsPopoverOpenTwo] = useState(false); - const toggleIsPopoverOpen = (shouldBeOpen = !isPopoverOpen) => { - setIsPopoverOpen(shouldBeOpen); - }; - const toggleIsPopoverOpenTwo = (shouldBeOpen = !isPopoverOpenTwo) => { - setIsPopoverOpenTwo(shouldBeOpen); - }; - - const input = ( - toggleIsPopoverOpen()} - aria-label="Popover attached to input element" - /> - ); - - const inputTwo = ( - { - setInputWidth(300); - toggleIsPopoverOpenTwo(); - }} - aria-label="Popover attached to an adjustable sized input element" - /> - ); + const [isResizablePopoverOpen, setIsResizablePopoverOpen] = useState(false); + const [anchorPosition, setAnchorPosition] = + useState('downLeft'); return ( - + <> { - toggleIsPopoverOpen(false); - }} + closePopover={() => setIsPopoverOpen(false)} + input={ + setIsPopoverOpen(true)} + placeholder="Focus me to toggle an input popover" + aria-label="Popover attached to input element" + /> + } > Popover content @@ -45,16 +35,46 @@ export default () => { { - toggleIsPopoverOpenTwo(false); - setInputWidth(200); - }} + display="inline-block" + isOpen={isResizablePopoverOpen} + closePopover={() => setIsResizablePopoverOpen(false)} + input={ + { + if (e.key === 'ArrowDown') { + e.preventDefault(); + setIsResizablePopoverOpen(true); + } + }} + placeholder="Focus me, press the down arrow key, then drag the resize handle" + aria-label="Press the down arrow key to toggle the popover attached to this textarea element." + rows={2} + resize="horizontal" + /> + } + panelMinWidth={300} + anchorPosition={anchorPosition} > - Popover will adjust in size as the input does + This popover has a minimum width of 300px, and will adjust in size as + the textarea does. + + + + setAnchorPosition(id as EuiInputPopoverProps['anchorPosition']) + } + options={[ + { id: 'downLeft', label: 'Left' }, + { id: 'downCenter', label: 'Center' }, + { id: 'downRight', label: 'Right' }, + ]} + /> + - + ); }; diff --git a/src-docs/src/views/popover/popover_example.js b/src-docs/src/views/popover/popover_example.js index 3aae5bef306..356288d8bbc 100644 --- a/src-docs/src/views/popover/popover_example.js +++ b/src-docs/src/views/popover/popover_example.js @@ -364,19 +364,20 @@ export const PopoverExample = {

EuiInputPopover is a specialized popover component intended to be used with form elements. Stylistically, the popover - panel is - {'"attached"'} to the input. Functionally, consumers have control - over what events open and close the popover, and it can allow for - natural tab order. + panel is {'"attached"'} to the input. As a result, the popover will + always try to set its width to match the width of the input, + although this can be configured via panelMinWidth + .

- Although some assumptions are made about keyboard behavior, - consumers should provide specific key event handlers depending on - the use case. For instance, a type=text input - could use the down key to trigger popover opening, but this - interaction would not be appropriate for{' '} - type=number inputs as they natively bind to the - down key. + Functionally, consumers have control over what events open and close + the popover, and it can allow for natural tab order. Although some + assumptions are made about keyboard behavior, consumers should + provide specific key event handlers depending on the use case. For + instance, a type=text input could use the down + key to trigger popover opening, but this interaction would not be + appropriate for type=number inputs as they + natively bind to the down key.

), diff --git a/src/components/form/super_select/__snapshots__/super_select.test.tsx.snap b/src/components/form/super_select/__snapshots__/super_select.test.tsx.snap index 6e9746896c8..5e7ab4e8b72 100644 --- a/src/components/form/super_select/__snapshots__/super_select.test.tsx.snap +++ b/src/components/form/super_select/__snapshots__/super_select.test.tsx.snap @@ -145,7 +145,7 @@ exports[`EuiSuperSelect props custom display is propagated to dropdown 1`] = ` class="euiPanel euiPanel--plain euiPopover__panel emotion-euiPanel-grow-m-plain-euiPopover__panel-bottom" data-popover-panel="true" role="dialog" - style="top: 8px; left: 0px; will-change: transform, opacity; z-index: 2000;" + style="top: 8px; left: -22px; will-change: transform, opacity; z-index: 2000;" >