polaris icon indicating copy to clipboard operation
polaris copied to clipboard

fillEvenly not working correctly when using a Select component with long values

Open cargix1 opened this issue 8 years ago • 5 comments

Issue summary

When using the fillEvenly distribution on my Stack the elements aren't distributed evenly when including a Select component with long values.

Expected behavior

I'd expect the Select component to be equally sized to the other components like so:

screen shot 2018-03-20 at 13 03 49

Actual behavior

When I increase the character length of the Select values the elements are no longer equally sized

screen shot 2018-03-20 at 12 52 19 screen shot 2018-03-20 at 12 55 50

Steps to reproduce the problem

  1. Here is some sample code you can use to replicate:
<Stack spacing="loose" alignment="fill" distribution="equalSpacing">
	<Stack.Item fill>
		<Stack distribution="fillEvenly">
			<Stack.Item>
				<Popover
					preferredPosition="below"
					activator={
						<TextField
							type="text"
							label="Select a date"
							labelHidden="true"
							placeholder="Select a date ..."
							prefix={<Icon source="calendar" color="skyDark"></Icon>}
							/>
					}>
					<DatePicker/>
				</Popover>
			</Stack.Item>
			<Stack.Item>
				<Select />
			</Stack.Item>
			<Stack.Item>
				<Select />
			</Stack.Item>							
		</Stack>
	</Stack.Item>
	<Stack.Item>
		<Button primary icon="export">Exportify</Button>
	</Stack.Item>
</Stack>

Just set the options of the Select component to something really long like: "Zapiet NYC my really long test name 1234"

Specifications

  • Polaris version: 1.12.2
  • React version: 15.6.1
  • Browser: Chrome (latest stable)
  • Device: Macbook Pro
  • Operating System: High Sierra

⚓️ We’re not accepting pull requests at this time
🗒 This repo is for reporting issues and feature requests only

cargix1 avatar Mar 20 '18 13:03 cargix1

@solonaarmstrong In this case I would aslo expect the selects to stay equally sized but the select options menu would resize with the length to the length of it's children. See attached for a visual. The transparent green boxes in the screenshot are just representing the size of the selects when the options menu is opened.

The screenshot also shows what the select would look like when the user selects an option that is longer than the select box itself. The text will just get cut-off.

screen shot 2018-04-11 at 1 48 12 pm

sarahill avatar Apr 11 '18 17:04 sarahill

I love this. Thank you, @sarahill

solonaarmstrong-zz avatar Apr 11 '18 17:04 solonaarmstrong-zz

We’ve started looking into a way to ensure the layout in this case works as expected.

ry5n avatar May 31 '18 23:05 ry5n

Because of the way flexbox works, this may not be something we can solve with the existing Stack component. We’re exploring some other options, but I wanted to give the heads up that a quick fix may not be on the way.

In the meantime, I would recommend creating a custom component (possibly based on Stack) that forces equal widths. (Stack is a general purpose component so its widths can’t be set in stone) CSS grid is worth looking into too, now that browser support is quite good.

ry5n avatar Jun 07 '18 02:06 ry5n

I have changed this from a bug report to a feature request. The fillEvenly prop in <Stack /> uses CSS flexbox with min-width: fit-content, so it's not a bug with <Stack />, it's a limitation of flexbox, unless we allow fixed widths, which isn't how that component is meant to be used.

A custom layout may be the best fix and in the meantime we're exploring the idea of a <Grid /> component that uses CSS grid.

solonaarmstrong-zz avatar Jun 08 '18 16:06 solonaarmstrong-zz