Page MenuHomePhabricator

Menu of DropdownWidget slightly off under certain circumstances
Closed, ResolvedPublic

Description

Steps to reproduce:

  1. Use Firefox (don't know whether this is a necessary step).
  2. Go to a page that is short enough to display without scrollbars (Special:BlankPage will probably do).
  3. Execute the following code:
mw.loader.using('oojs-ui').done(function () {
	function MyPage () {
		var fieldsetLayout, dropdownWidget;
		MyPage.parent.apply(this, arguments);
		dropdownWidget = new OO.ui.DropdownWidget({
			$overlay: $('body'),
			menu: {
				items: [
					new OO.ui.MenuOptionWidget({label: 'a'}),
					new OO.ui.MenuOptionWidget({label: 'b'}),
					new OO.ui.MenuOptionWidget({label: 'c'})
				]
			}
		});
    fieldsetLayout = new OO.ui.FieldsetLayout({label: 'Foo'});
    fieldsetLayout.addItems([new OO.ui.FieldLayout(dropdownWidget, {label: 'Bar', align: 'left'})])
		this.$element.append(
			$('<p>').height(300),
			fieldsetLayout.$element,
			$('<p>').height(900)
		);
	}

	OO.inheritClass(MyPage, OO.ui.PageLayout);

	var booklet, panel;
	booklet = new OO.ui.BookletLayout({continuous: true});
	booklet.addPages([new MyPage('x', 'Title')]);
	panel = new OO.ui.PanelLayout({
		content: [booklet],
		expanded: false,
		framed: true
	});

  var $content = $('#bodyContent'), $panel = panel.$element;
  $content.empty().append($panel.height(300));
	function resize () {
		$panel.height(Math.max(
			$(window).height() - $content.offset().top - $panel.offset().top,
			400
		));
	}

	$(window).on('resize', resize);
	resize();
});
  1. Note that the page still doesn't have a scrollbar (if it has one, then adapt the sizes in the above code to fit your screen).
  2. Open the dropdown.

Expected: The menu should be exactly below it.
Actual: It's a few pixels (width of a scrollbar?) too far left, the total width is correct.

Note that:

  • When you resize the window while the dropdown is open to a size with scrollbars (e.g. by opening the browser console), the menu is positioned correctly, but it is too wide.
  • When the page has a scrollbar and you open the dropdown, it is positioned correctly and has the correct width.
  • I can't reproduce the issue without the FieldsetLayout, adding the DropdownWidget directly to the page seems to work.
  • Depending on your version you might run into T157936: Menu of DropdownWidget gets separated on scrolling inside continuous BookletLayout with this code.

Event Timeline

Now with T157936 fixed, scrolling the BookletLayout also fixes the position of the dropdown.

@Schnark that does sound like a duplicate of T168703. Is it the same issue with your code as in https://doc.wikimedia.org/oojs-ui/master/demos/demos.php?page=widgets&theme=wikimediaui&direction=ltr with the DropdownInputWidgets there?

As I wrote it seems related, but I don't think it is a duplicate. Even if the width can't be fixed, the alignment can and should be corrected (as it fixes itself on a resize, this must be possible).

Volker_E claimed this task.

@Schnark Seems resolved with OOUI v0.27.0:

image.png (940×2 px, 56 KB)

Initial appearance, featuring both, scrollbar on full window and within #bodyContent