material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[AutoComplete]

Open hmeerlo opened this issue 10 years ago • 7 comments

Description

Can not set width of dropdown I want an autocomplete field where the searchfield should be smaller than the contents of the dropdown.

Images & references

screen shot 2016-06-22 at 22 00 21

hmeerlo avatar Jun 22 '16 20:06 hmeerlo

You can set a custom width through listStyle:

<AutoComplete
  listStyle={{
    width: 500,
  }}
  hintText="Type anything"
  dataSource={this.state.dataSource}
  onUpdateInput={this.handleUpdateInput}
/>

finaiized avatar Jun 22 '16 23:06 finaiized

Ah thanx, I will give it a try. It is very hard to find this out at the moment. I really hope the new styling mechanism coming in 0.16 is making this better (but more importantly that it improves the performance because that should be priority 1 for this project in my opinion).

hmeerlo avatar Jun 23 '16 06:06 hmeerlo

@hmeerlo Were you able to resolve the issue with the solution posted above?

aahan96 avatar Jul 05 '16 19:07 aahan96

Yes partially. You cannot set fullWidth to true because then it won't work. That's too bad because I wanted my searchField to be fullWidth of the enclosing div and the dropdown wider than that.

hmeerlo avatar Jul 05 '16 19:07 hmeerlo

You can set a custom width through listStyle:

<AutoComplete
  listStyle={{
    width: 500,
  }}
  hintText="Type anything"
  dataSource={this.state.dataSource}
  onUpdateInput={this.handleUpdateInput}
/>

@oliviertassinari is that listStyle props still exist on the autoComplet component?

hadasmaimon avatar Apr 20 '20 17:04 hadasmaimon

@oliviertassinari what is the alternative of it?

hadasmaimon avatar Apr 20 '20 18:04 hadasmaimon

@oliviertassinari what is the alternative of it?

This is the alternative:

<AutoComplete
  ListboxProps={{ style: { maxHeight: 200, overflow: 'auto' } }}
...
/>

hadasmaimon avatar Apr 21 '20 09:04 hadasmaimon