Skip to content
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

Add popoverPlacement prop in EuiDatePicker #3359

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Added `showCloseButton` and `dockedBreakpoint` flexibility to `EuiCollapsibleNav` ([#3330](https://github.com/elastic/eui/pull/3330))
- Added `panelStyle` prop to `EuiPopover` to distinguish style object configuration ([#3329](https://github.com/elastic/eui/pull/3329))
- Expose `popperPlacement` prop in `EuiDatePicker` ([#3359](https://github.com/elastic/eui/pull/3359))
elizabetdev marked this conversation as resolved.
Show resolved Hide resolved

**Bug Fixes**

Expand Down
1 change: 1 addition & 0 deletions src-docs/src/views/date_picker/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class extends Component {
isInvalid={this.state.startDate > this.state.endDate}
aria-label="End date"
showTimeSelect
popperPlacement="bottom-end"
elizabetdev marked this conversation as resolved.
Show resolved Hide resolved
/>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ exports[`EuiDatePicker is rendered 2`] = `
onMonthChange={[Function]}
onSelect={[Function]}
onYearChange={[Function]}
popperPlacement="bottom-start"
preventOpenOnFocus={false}
previousMonthButtonLabel="Previous Month"
readOnly={false}
Expand Down
21 changes: 21 additions & 0 deletions src/components/date_picker/date_picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ export const euiDatePickerDefaultTimeFormat = 'hh:mm A';

const DatePicker = _ReactDatePicker as typeof ReactDatePicker;

export type EuiDatePickerPopperPlacement =
elizabetdev marked this conversation as resolved.
Show resolved Hide resolved
| 'bottom'
| 'bottom-end'
| 'bottom-start'
| 'left'
| 'left-end'
| 'right'
| 'right-end'
| 'right-start'
| 'top'
| 'top-end'
| 'top-start';

interface EuiExtendedDatePickerProps extends ReactDatePickerProps {
/**
* Applies classes to the numbered days provided. Check docs for example.
Expand Down Expand Up @@ -89,6 +102,11 @@ interface EuiExtendedDatePickerProps extends ReactDatePickerProps {
* Show the icon in input
*/
showIcon?: boolean;

/**
* Open the popper in one of the positions
*/
popperPlacement?: EuiDatePickerPopperPlacement;
elizabetdev marked this conversation as resolved.
Show resolved Hide resolved
}

type _EuiDatePickerProps = CommonProps & EuiExtendedDatePickerProps;
Expand All @@ -109,6 +127,7 @@ export class EuiDatePicker extends Component<_EuiDatePickerProps> {
showIcon: true,
showTimeSelect: false,
timeFormat: euiDatePickerDefaultTimeFormat,
popperPlacement: 'bottom-start',
};

render() {
Expand Down Expand Up @@ -138,6 +157,7 @@ export class EuiDatePicker extends Component<_EuiDatePickerProps> {
openToDate,
placeholder,
popperClassName,
popperPlacement,
selected,
shadow,
shouldCloseOnSelect,
Expand Down Expand Up @@ -262,6 +282,7 @@ export class EuiDatePicker extends Component<_EuiDatePickerProps> {
utcOffset={utcOffset}
yearDropdownItemNumber={7}
accessibleMode
popperPlacement={popperPlacement}
{...rest}
/>
);
Expand Down