-
Notifications
You must be signed in to change notification settings - Fork 78
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
fix: Align popover inside dropdown #789
fix: Align popover inside dropdown #789
Conversation
Check the deploy log for errors here: https://app.netlify.com/sites/fundamental-react/deploys Built with commit ad7f0ed https://app.netlify.com/sites/fundamental-react/deploys/5dd831e64b7c120008d946bc |
src/Popover/Popover.js
Outdated
}; | ||
|
||
Popover.propDescriptions = { | ||
body: 'Node(s) to render in the overlay.', | ||
control: 'Node to render as the reference element (that the `body` will be placed in relation to).', | ||
disableEdgeDetection: 'Set to **true** to render popover without edge detection so popover will not flip from top to bottom with scroll.', | ||
noArrow: 'Set to **true** to render a popover without an arrow.', | ||
parentElement: 'A reference (useRef) to an element of which the Popover will be positioned and sized relatively. Leave it empty to let it be done automatically.', |
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.
Can we call this parentRef
to be even more explicit?
And if we're going to mention useRef()
, can we clarify the function itself shouldn't be passed in, but rather the return object from calling it?
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.
Also, the description seems to imply ("let it be done") that positioning and sizing relative to its parent can happen automatically if left empty. Is that the case?
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.
Sadly, it's not. If it was, this PR wouldn't need to exist at all ;)
I had no idea how to let the developer know he should put useRef's result there... Your idea of parentRef
seems reasonable.
I tried to put some comments into the code displayed in the documentation website but it's impossible :(
src/utils/_Popper.js
Outdated
@@ -94,6 +95,11 @@ class Popper extends React.Component { | |||
if (!show) { | |||
return null; | |||
} | |||
const currentParentElement = parentElement && parentElement.current; |
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.
Regarding my other comment, parentRef
would be slightly clearer here that we could access a property .current
.
@parostatkiem - can you add before and after screen caps? |
@bcullman you can clearly see it live on the deployed preview. Open the Width limited to parent's dropdown, then open any other one. You'll see the difference :) |
1f61f0e
to
0ffcaa0
Compare
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.
This needs some unit tests added and screenshots - while I understand we can currently see it with the deploy preview, for history's sake if we need to look back it's better to have some screenshots in the description.
@jbadan ✅done |
@parostatkiem - I could imagine a better long term fix would be to address this here by adding a opt-in prop for `widthSizingType' here: https://github.com/SAP/fundamental-react/blob/master/src/utils/_Popper.js that accepted the following
it would fix this component, and be flexible enough to handle all other circumstances, including other copmponets relying on |
@bcullman - where it would take the target's width from? The problem is Popper has no "idea" of his parent. That's why I introduced ... or do you mean adding |
@parostatkiem The |
…o align-popover-inside-dropdown # Conflicts: # src/Popover/Popover.js
@greg-a-smith it was the first place I tried to find a solution at but I couldn't get the real DOM node of the @bcullman I implemented your idea in an unchanged form. I finally got rid of a ref on the client side :) |
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.
There appears to be some display issues with the popover examples using the Menu
component, but I think that's another issue altogether. Not sure why Menu
is a display type of table
, but it is. 🤔 This is part of the reason why new Select
and List
components were built in fundamental-styles
. The down side is they haven't been created in fundamental-react
yet. 😞 Let's go forward with these changes for now and revisit if and when necessary. 🚢
@parostatkiem I tried to resolve some conflicts for you here, but I can't push to your branch to fix the failing test. Ping the team when the tests pass and we will merge :) |
@jbadan I added you to collaborators, you should receive an invitation email. |
closing for #804 |
This is a temporary solution.
The whole problem requires a major refactoring on popovers, as @jbadan said on Slack (100% agree).
⚠️ It does not introduce any backwards-incompatible changes.
This is just a "patch" to make Popover working with Dropdown or any other element.
Description
It works well with Dropdown as well as any other type.
Sadly, the solution requires creating a reference on the client side.Before:
After:
fixes #788