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

Making select width equal to width of wrapping parent #2956

Closed
hari5004 opened this issue Sep 20, 2018 · 9 comments · Fixed by #4841
Closed

Making select width equal to width of wrapping parent #2956

hari5004 opened this issue Sep 20, 2018 · 9 comments · Fixed by #4841

Comments

@hari5004
Copy link

Environment

  • Package version(s): 3.x
  • Browser and OS versions: NA

Question

How to set the width of select component to match the width of its parent div.

@giladgray giladgray changed the title Making select width equal to fidth of wrapping parent Making select width equal to width of wrapping parent Sep 20, 2018
@giladgray
Copy link
Contributor

@hari5004 a few options:

  1. usePortal={false} and then add some width: 100% / fill modifiers will allow the select and target to easily share dimensions.
  2. hardcode width on both.
  3. submit a PR to add support for this in the components.

@giladgray
Copy link
Contributor

also see #2094

@eliekhoury
Copy link

  1. hardcode width on both.

@giladgray what would be the best way to set the width of the Select popover?

@gorazu
Copy link

gorazu commented Feb 4, 2019

hello, I have a similar issue, I set the popoverProps with usePortal={false} then if I add width: 100% to bp3-popover and bp3-transition-container its still not working (even with container set to display: block.

I see that a translate 3d is set tot the bp3-transition-container but I can not override it to display the popover relative to the container.

ps: with hardcoded width on both target and menu it works fine.

any advices @giladgray ?

@Cody0913
Copy link

Cody0913 commented Apr 8, 2019

I was looking into this as it is a very common item I use and would love to see this enhancement implemented.
I started working on a few different tests in seeing how to accomplish this (as I do not commonly work with ts).
My proposal, and I have made these changes locally, is to add a fill param on the popover and set it as true when passing the popoverProps from the Select (this would also require a fill param passed to the input/button used in either a Select, Suggest, etc. I also made a change so that when the fill prop is true in the popover this param is also added to child in which this wraps.
I was going to try and simplify it even further so that this prop is set on the Select and is passed through this same method for simplicity.

fillTest

My changes were adding what was above for props but also having it so that anywhere a condition was being used for usePortal would also take into account if fill is set as these would conflict with each other.

I also added so that where popper calculates it's transition if fill is set to true then it will not calculate and instead will just have a bp3-fill class added, with the appropriate style added. Since this is removed it no longer gets position absolute.

If anyone has any other suggestions or methods to perform this I am all ears. Figured I'd take a whack at it and that is the solution I found easiest with the least amount of interference.

@LoiKos
Copy link

LoiKos commented Mar 20, 2020

Still having the issue with Select popover width ! I think this is a huge improvement to get something to do it automatically and stop hardcode width to make it work.

@adidahiya
Copy link
Contributor

The fill prop was added to Popover, Suggest, and MultiSelect here: #3636. It should be pretty easy to make a PR to add the same prop to Select, following the code in that PR.

@LoiKos
Copy link

LoiKos commented Mar 25, 2020

@adidahiya i'll try to take a look but can't say when. btw MultiSelect fill props work fine for TagInput but for popover it add the bp3-fill class on div with class bp3-popover-wrapper but that doesn't fit as expected because bp3-transition-container doesn't fill parent.

And you need to define usePortal on popover to false too

@aamirbutt
Copy link

Hi guys, any update on when this will be implemented as part of the library?
I am on @blueprintjs/select 3.14.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants