Page MenuHomePhabricator

D20383.id48628.diff
No OneTemporary

D20383.id48628.diff

diff --git a/webroot/rsrc/js/phuix/PHUIXDropdownMenu.js b/webroot/rsrc/js/phuix/PHUIXDropdownMenu.js
--- a/webroot/rsrc/js/phuix/PHUIXDropdownMenu.js
+++ b/webroot/rsrc/js/phuix/PHUIXDropdownMenu.js
@@ -198,7 +198,35 @@
var v = JX.$V(this._node);
var d = JX.Vector.getDim(this._node);
- switch (this.getAlign()) {
+ var alignments = ['right', 'left'];
+ var disallow = {};
+ var margin = 8;
+
+ // If "right" alignment would leave us with the dropdown near or off the
+ // left side of the screen, disallow it.
+ var x_min = ((v.x + d.x) - m.x);
+ if (x_min < margin) {
+ disallow.right = true;
+ }
+
+ var align = this.getAlign();
+
+ // If the position disallows the configured alignment, try the next
+ // best alignment instead.
+
+ // If no alignment is allowed, we'll stick with the original alignment
+ // and accept that it isn't going to render very nicely. This can happen
+ // if the browser window is very, very small.
+ if (align in disallow) {
+ for (var ii = 0; ii < alignments.length; ii++) {
+ if (!(alignments[ii] in disallow)) {
+ align = alignments[ii];
+ break;
+ }
+ }
+ }
+
+ switch (align) {
case 'right':
v = v.add(d)
.add(JX.$V(-m.x, 0));

File Metadata

Mime Type
text/plain
Expires
Mar 25 2025, 1:13 AM (4 w, 5 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7721075
Default Alt Text
D20383.id48628.diff (1 KB)

Event Timeline