Closed RajRohitYadav closed 3 years ago
Thanks for the PR, I like the idea a lot! You're work on computeAutoGeometry
is appreciated.
What do you think of, instead of creating a new prop, overloading the existing placement
prop to accept an array in addition to a single value? That way, when they pass in an a single value, it would be treated as an array with one value, and then all placements would be evaluated as an array. I'm thinking something like this:
['top'] // Always place on top
['top', 'bottom'] // Place on top if it fits, otherwise on bottom. If it doesn't fit top or bottom, prefer top (first in list)
['top', 'bottom', 'auto'] // Try top, then bottom, then fallback to auto placement (pick best fit)
['right', 'bottom', 'top'] // You get the idea...
['auto'] // Use auto placement (default)
What are your thoughts? I'm not necessarily asking you to make this change, just want to discuss for now.
Yup, sounds good. Implementing this in existing props is more sensible. However, should take care of backward compatibility.
So, I will remove the placementPriority
prop and logic for now. Only auto-placement enhancement logic will be there.
I will make another PR for the suggested change of using placement
for handling an array and string.
I have done the changes.
Removed placementPriority
and related code.
Ok, sounds good!
Hey @SteffeyDev,
I was planning to start the suggested change today, but after a pull from base, there are errors. After clearing those errors in my local I found the popover is not working as expected.
Please have a look.
Sorry about that, I was doing some refactoring and didn't fully test it. I'll get that fixed.
I just tested and everything is working as expected, @RajRohitYadav can you be more specific about the errors you are seeing?
@RajRohitYadav I discovered the errors and have fixed them. Also, updated the repo so that all development is done on the develop
branch, so please switch to using that branch for PRs.
Thank you for the update, I will work on it asap
Hello @SteffeyDev, have made PR for the above changes in #141 I have tested it, but need your help in testing as I'm not aware of the edge/other cases in the product.
new optional prop added:
priorityPlacement
This prop is an array with a list of sides based on priority.ex:
priorityPlacement = {['left', 'bottom']}
will try to render first left, then bottom. If failed it will find the best space to render it, based on available space on all sides.computeAutoGeometry
is equipped with handlingpriorityPlacement
based on the best area available for the popover. Also, new logic incomputeAutoGeometry
will make sure popover is rendered more gracefully in best available area.