PDA

View Full Version : [OPEN-1312] Menu with maxHeight has incorrect aligning



vladsch
5 Oct 2010, 7:54 AM
Hi,

If define maxHeight for the menu then the menu is shown at incorrect position

Please see the following sample


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Toolbar with Menus</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />

<!-- GC -->
<!-- LIBS -->
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<!-- ENDLIBS -->

<script type="text/javascript" src="../../ext-all.js"></script>

<script type="text/javascript">
Ext.onReady(function(){
var tb = new Ext.Toolbar();
tb.render('toolbar');

var scrollMenu = new Ext.menu.Menu({maxHeight:200});
for (var i = 0; i < 50; ++i){
scrollMenu.add({
text: 'Item ' + (i + 1)
});
}

// scrollable menu
tb.add({
text: 'Scrolling Menu',
menu: scrollMenu
});

tb.doLayout();
});
</script>
</head>
<body>
<br /><br /><br /><br /><br />

<div id="container">
<div id="toolbar"></div>
</div>

<br /><br /><br /><br /><br />
</body>
</html>

Condor
8 Oct 2010, 12:43 AM
I tried to fix the y calculation in constrainScroll, but I couldn't.

The returnY only needs to be increased (and NOT decreased!) if:
1. The menu was top aligned.
2. The menu was bottom aligned, but pushed up by the '?' constraint.
but unfortunately, alignment information is not available in constrainScroll.

To do this correctly showAt will have to be modified, so it determines the height of the menu first and then aligns it.