Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/components/Input/DateInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default class DateInput extends React.Component {
showOnFocus: PropTypes.bool,
state: PropTypes.any,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
container: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
};

static defaultProps = {
Expand Down Expand Up @@ -309,6 +310,7 @@ export default class DateInput extends React.Component {
positionFixed,
value,
state,
container,
...props
} = this.props;
/* eslint-enable @typescript-eslint/no-unused-vars */
Expand Down Expand Up @@ -353,7 +355,12 @@ export default class DateInput extends React.Component {
</Button>
</InputGroup>
</DropdownToggle>
<DropdownMenu className="p-0" onKeyDown={this.onKeyDown} {...dropdownProps}>
<DropdownMenu
className="p-0"
onKeyDown={this.onKeyDown}
container={container}
{...dropdownProps}
>
{renderHeader(this.prevMonth, this.nextMonth, this.prevYear, this.nextYear) || header || (
<header className="d-flex py-2">
<ButtonGroup size="sm">
Expand Down
32 changes: 32 additions & 0 deletions src/components/Input/DateInput.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ WithProps.args = {
onChange: action('onChange'),
onClose: action('onClose'),
positionFixed: false,
container: undefined,
};

export const WithId = (args) => (
Expand Down Expand Up @@ -163,3 +164,34 @@ export const CalendarCustomDay = (args) => (
/>
</div>
);

export const WithContainer = (args) => (
<div>
<p>
The container prop allows you to specify where the dropdown menu is rendered. Use
&apos;body&apos; to avoid z-index issues or provide a custom container element.
</p>
<div
id="constrained-container"
style={{
position: 'relative',
overflow: 'hidden',
height: '310px',
border: '1px solid #ccc',
padding: '10px',
}}
>
<p>This container has overflow: hidden and limited height</p>
<DateInput container="body" placeholder="Container = body" {...args} />
<br />
<br />
<DateInput container="#constrained-container" placeholder="Container = this div" {...args} />
<br />
<br />
<DateInput placeholder="Default positioning (may be clipped)" {...args} />
</div>
</div>
);
WithContainer.args = {
onChange: action('onChange'),
};
Loading