question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong fixed menu positioning inside a containing block

See original GitHub issue

When using the Select with menuPosition="fixed" inside a parent that is a containing block (all fixed positioned children are positioned relative to it, which can be done using transform: "translate(0)" for example on any of its parents), this causes wrong calculation for the left positioning… is there a way to calculate the left position against some parent element?

CodeSandBox: https://codesandbox.io/s/react-select-forked-x7lb6?file=/example.js:515-541

Untitled

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
viriyadhikacommented, Jul 20, 2021
<Select
   styles={{
      container: () => ({
         position: "static",
         boxSizing: "border-box"
      }),
      menu: () => ({
        position: "fixed",
        width: "50%",
        right: 40
      })
   }}
   value={this.state.value}
   onChange={this.handleChange}
   isMulti
   name="colors"
   options={colourOptions}
   className="basic-multi-select"
   classNamePrefix="select"
/>

It works when menu is positioned at fixed as well. And if we put other elements you can also see that the menu is not a part of the parent flow. Not too sure if this is what you meant tho

<div>
   <Select ... />
   <Others .../>
</div>
0reactions
ebonowcommented, Oct 17, 2021

This appears to be resolved as the transform is causing the misalignment and if it is necessary for boundary purposes, then menuPortal will likely be the preferred method.

I will close this, but if there are other concerns or objections, we can discuss further and reopen if necessary.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixed position but relative to container - Stack Overflow
However, the div is inside a centered container. When I use position:fixed it fixes the div relative to the browser window, such as...
Read more >
Layout and the containing block - CSS: Cascading Style Sheets
If the position property is fixed , the containing block is established by the viewport (in the case of continuous media) or the...
Read more >
CSS absolute and fixed positioning - W3C Wiki
Fixed positioning is really just a specialized form of absolute positioning; ... In this case the containing block is the nearest positioned ancestor....
Read more >
Absolute, Relative, Fixed Positioning: How Do They Differ?
The concern with fixed positioning is that it can cause situations where the fixed element overlaps content such that is is inaccessible. The ......
Read more >
Position | Webflow University
Every element has a static position by default, so the element will stick to the document flow. Elements with static positioning appear in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found