feat(WW-4125): bindable position + auto vertical/horizontal opening direction - #18
Open
kevinbarfleur wants to merge 2 commits into
Open
feat(WW-4125): bindable position + auto vertical/horizontal opening direction#18kevinbarfleur wants to merge 2 commits into
kevinbarfleur wants to merge 2 commits into
Conversation
leo91000
requested changes
Jul 23, 2026
Comment on lines
95
to
176
| @@ -104,6 +106,73 @@ export default { | |||
| width: box.width, | |||
| height: box.height, | |||
| }; | |||
| computeResolvedPosition(); | |||
| }; | |||
|
|
|||
| const computeResolvedPosition = () => { | |||
| const position = props.content.position; | |||
| const box = triggerBox.value; | |||
| if (!box || box.width === undefined) { | |||
| resolvedPosition.value = position; | |||
| return; | |||
| } | |||
|
|
|||
| const frontWindow = wwLib.getFrontWindow(); | |||
| const viewportHeight = frontWindow.innerHeight; | |||
| const viewportWidth = frontWindow.innerWidth; | |||
|
|
|||
| const dropdownRect = dropdownElementRef?.value?.getBoundingClientRect(); | |||
| const dropdownHeight = dropdownRect?.height || box.height; | |||
| const dropdownWidth = dropdownRect?.width || box.width; | |||
|
|
|||
| const parseOffset = (value) => { | |||
| const parsed = parseFloat(value); | |||
| return Number.isFinite(parsed) ? parsed : 0; | |||
| }; | |||
| const offsetY = parseOffset(props.content.offsetY); | |||
| const offsetX = parseOffset(props.content.offsetX); | |||
|
|
|||
| if ( | |||
| props.content.autoVertical && | |||
| (position === "top" || position === "bottom") | |||
| ) { | |||
| const spaceBelow = viewportHeight - box.bottom - offsetY; | |||
| const spaceAbove = box.top - offsetY; | |||
| const fitsBelow = spaceBelow >= dropdownHeight; | |||
| const fitsAbove = spaceAbove >= dropdownHeight; | |||
| if (!fitsBelow && (fitsAbove || spaceAbove > spaceBelow)) { | |||
| resolvedPosition.value = "top"; | |||
| } else { | |||
| resolvedPosition.value = "bottom"; | |||
| } | |||
| return; | |||
| } | |||
|
|
|||
| if ( | |||
| props.content.autoHorizontal && | |||
| (position === "left" || position === "right") | |||
| ) { | |||
| const spaceRight = viewportWidth - box.right - offsetX; | |||
| const spaceLeft = box.left - offsetX; | |||
| const fitsRight = spaceRight >= dropdownWidth; | |||
| const fitsLeft = spaceLeft >= dropdownWidth; | |||
| if (position === "right") { | |||
| if (!fitsRight && (fitsLeft || spaceLeft > spaceRight)) { | |||
| resolvedPosition.value = "left"; | |||
| } else { | |||
| resolvedPosition.value = "right"; | |||
| } | |||
| } else { | |||
| if (!fitsLeft && (fitsRight || spaceRight > spaceLeft)) { | |||
| resolvedPosition.value = "right"; | |||
| } else { | |||
| resolvedPosition.value = "left"; | |||
| } | |||
| } | |||
| return; | |||
| } | |||
|
|
|||
| resolvedPosition.value = position; | |||
| }; | |||
Contributor
There was a problem hiding this comment.
Est-ce qu’on devrait plutôt se baser sur les dimensions réellement rendues du dropdown ? Avec parseFloat, un offset comme 10% est interprété comme 10px et une variable CSS comme 0, ce qui peut choisir la mauvaise direction.
Comment on lines
+294
to
+303
| watch( | ||
| () => [ | ||
| props.content.position, | ||
| props.content.autoVertical, | ||
| props.content.autoHorizontal, | ||
| ], | ||
| () => { | ||
| computeResolvedPosition(); | ||
| } | ||
| ); |
Contributor
There was a problem hiding this comment.
Est-ce qu’on devrait aussi relancer le calcul quand offsetX, offsetY ou la taille du contenu changent ? Aujourd’hui, un offset bindé ou du contenu chargé après l’ouverture peut faire déborder le dropdown sans nouveau calcul.
leo91000
approved these changes
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.