[detachable] Add ability to flip popover element#168
[detachable] Add ability to flip popover element#168DerrikMilligan wants to merge 2 commits intoantoniandre:mainfrom
Conversation
…lement if it's not visible on the page. Similar to how the @floating-ui/dom's flip middleware works. Also updated some type definitions to include the detachable where that mixin is used.
…revious flipping implementation. Still needs more work but it's getting closer.
|
This may have to be put on hold it turns out it's a lot more complicated than just what I have ha. There are a lot of edge cases where this doesn't work. |
|
Thanks for these thoughts and your work @DerrikMilligan! If you feel like you can have a go, otherwise I'll work on it soon. Just to be in sync, all the components are ready to be converted to composition API 1 by 1. No need to convert them all at once. Cheers! |
Attempted to fix the last part of detachable where we can 'flip' an element if it's not visible on the page. Similar to how floating-ui's flip middleware works.
Changes made:
allowFlipprop which hides this behavior if you don't want it. Defaults totrueresizeandscrollevents for the page to re-calculate if a flip needs to occur.detachablew-tooltipandw-menu's props extend this interface as they directly utilize the mixinmenuprop ofw-confirmnow utilizes the types fromw-menumenuPropsprop ofw-selectnow utilizes the types fromw-menuExample
Here is an example of how that looks from the documentation:


Before the flip:
After the flip:
The pink line is the bottom of my browser window. Since there's no room for the menu it's "flipped" to be displayed on the top. A similar process will take place with flipping left and right aligned items.
Future refinements
middlewarethat floating UI implements that we may want to consider adding as well, the shift middleware which will move the element to stay in view even if the activator element is not in viewflipmiddleware such as restricting flipping across various axesFinal Thoughts
Overall this is just 1 step in trying to have a better overall popover experience without including an external library. But I think that it's a good step in the right direction. Looking forward to see what @antoniandre thinks.