-
Notifications
You must be signed in to change notification settings - Fork 53
Conversation
const { target } = this.state | ||
|
||
const placement = computePopupPlacement({ align, position, rtl }) | ||
|
||
const popperModifiers = { | ||
// https://popper.js.org/popper-documentation.html#modifiers..offset | ||
...(offset && { offset: { offset: this.applyRtlToOffset(offset, rtl, position) } }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad applying modifiers is the only way we can adjust the offset... There is no way we can use this prop inside the styles in order to achieve the position, right? It really feels awkward to have to tackle rtl in the component's logic..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, there is no any - so, there are several reasons for that.
First is simple - there are no additional props of Popper that would allow client to customize positioning (actually, good thing). And here we are getting to the next alternative option that might come to mind (the one you've mentioned) - use styles for influencing these offsets.
I've tried this one - and have done that only to clearly see that even in LTR mode taken in isolation we have lots of issues. As an example: if it is about 'start' value for align
property, which corresponds to popup aligned with the left side of trigger,
we might use left
to specify an offset (as absolute
positioning strategy is used by Popper). However, when we will achieve necessary result and switch to the ride sides alignment, we will see that Popper is using transform
property to ensure alignment for the right sides, and here we cannot use offsets of left-right
CSS properties anymore.
For the sake of not preventing havoc to wreak our code, decided to just reuse solution Popper has already introduced for solving exactly this problem (probably, the most reasonable thing) - and this, in fact, what we've done with the modifiers. Note, we are not abusing it - we are using the tool from Popper that is, actually, dedicated to solve this exact problem :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for the functionality... Let's try to move somehow the offset in the styles if it is possible before merging (I don't think it is, but I had to mention it).
moving offset to the styles is possible, but it will lead to the following reasonable question:
To me it seems reasonable to have this being part of the component's API (the same reasoning for having So, while understand your concerns, feel that have both as part of component's API is preferred. |
@kuzhelov - sorry that I hadn't managed to comment on this before merging.
Code: { position: 'above', align: 'start', offset: '-100%p + 50%, 10px', rotateArrowUp: '-45deg' },
Code (200px offset vs 80px trigger): { position: 'above', align: 'start', offset: '200px, 10px', rotateArrowUp: '-45deg' }, |
This PR introduces
offset
prop to thePopup
API that would allow client to fine-tune position of the rendered popup. Effect of this prop's value is intuitive to the client, RTL mode is also respected.TODO
Values supported
Example
No Offset (align: start)
With Offset (align: start, offset: 100%)
Fixes #313