polaris icon indicating copy to clipboard operation
polaris copied to clipboard

DatePicker component is not displaying as it should when used within a Popover component.

Open cargix1 opened this issue 9 years ago • 3 comments

Issue summary

DatePicker component is not displaying as it should when used within a Popover component.

Expected behavior

I'd expect the DatePicker / Popover component to appear over subsequent elements in my form.

Actual behavior

The DatePicker and Popover is been hidden behind the next TextField element.

screen shot 2017-06-26 at 16 07 15

Steps to Reproduce the Problem

  1. Use the code below:
<div>
	<Popover
		active
		activator={
			<TextField
				type="text"
				label="Pickup date"
				placeholder="Select a date ..."
				prefix={<Icon source="calendar" color="black"></Icon>}
				value="2017-06-10"
			/>
		}>
			<DatePicker
				month="5"
				year="2017"
			/>
	</Popover>
	<TextField
		type="text"
		label='Pickup time'
		placeholder="Select a time ..."
		prefix={<Icon source="calendar" color="black"></Icon>}
	/>
</div>
  1. Fire up your browser, and you'll see the calendar/popover lying underneath the pickup time field.

Specifications

  • Polaris version: 1.1.1
  • React version: 15.4.2
  • Browser: Chrome
  • Device: MacBook Pro
  • Operating System: Sierra

cargix1 avatar Jun 26 '17 15:06 cargix1

Hey @cargix1, thanks for the issue. We don't really document this anywhere, but Popover (and Tooltip) decide where to stack based on a special selector, data-polaris-layer. It looks up the DOM from the activator, finds the first node with data-polaris-layer, and sets the Popover's z-index to be that node's z-index + 1. So, I think to resolve this, the simplest thing to do would be something like this:

<div data-polaris-layer style={{position: relative, z-index: 1}}>
	<Popover
		active
		activator={
			<TextField
				type="text"
				label="Pickup date"
				placeholder="Select a date ..."
				prefix={<Icon source="calendar" color="black"></Icon>}
				value="2017-06-10"
			/>
		}>
			<DatePicker
				month="5"
				year="2017"
			/>
	</Popover>
	<TextField
		type="text"
		label='Pickup time'
		placeholder="Select a time ..."
		prefix={<Icon source="calendar" color="black"></Icon>}
	/>
</div>

Let me know if this does not work, and I'll also make a note for us to document this.

lemonmade avatar Jun 27 '17 13:06 lemonmade

Hey @lemonmade, thanks for replying so quick! I've just given it a test and it appears to work great thanks!

screen shot 2017-06-27 at 15 06 39

One thing I did discover was that in the code above I was passing the month and year through like month="5" and year="2017" rather then month={5} and year={2017} as stated in the documentation. This caused the calendar to appear but not include any actual dates. So just incase anyone else uses the code above just update the DatePicker component as shown below:

<DatePicker
  month={5}
  year={2017}
/>

cargix1 avatar Jun 27 '17 14:06 cargix1

Hi !

I tried the following approach but I still have some position issue on tooltip, which seems to position against the wrong element:

capture d ecran 2017-07-12 a 14 41 25

In this example the tooltip is wrapping the "Order #1001" at the bottom. What is the correct way to make the tooltip work? :)

bakura10 avatar Jul 12 '17 12:07 bakura10