Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

submenu can't automatically adjust width #18

Closed
bbjj702 opened this issue Dec 22, 2011 · 7 comments
Closed

submenu can't automatically adjust width #18

bbjj702 opened this issue Dec 22, 2011 · 7 comments

Comments

@bbjj702
Copy link

bbjj702 commented Dec 22, 2011

When submenu width is larger then min-width, submenu can't automatically adjust width.

@rodneyrehm
Copy link
Contributor

Fun problem… I have no clue why this is happening. Since my tests failed, I posted a question on StackOverflow.

@rodneyrehm
Copy link
Contributor

I guess I'll have to temporarily make the menu and sub-menus position:static to calculate the widths of the sub-menus. Sort of sucks, but is the simplest solution I could think up. Anyone has a different solution in mind?

rodneyrehm added a commit that referenced this issue Dec 25, 2011
@rodneyrehm
Copy link
Contributor

Fixed in version 1.5.2

baohx2000 pushed a commit to Contatta/jQuery-contextMenu that referenced this issue Jun 18, 2012
@AAverin
Copy link

AAverin commented Dec 4, 2012

Funny thing.
I've just updated contextMenu in the project, and got a strange issue with root menu trying to increase it's width, resulting in graphical corruptions.
Search lead to this case.
If I got the code right, you recalculate width of menus and force it via css width property?
The problem here is that submenu at the moment of calcaulation isn't yet properly positioned with the root menu, so when you call

opt.$menu.find('ul').andSelf().css({position: 'static', display: 'block'})

you make all menus (root and all sub's) visible at once, and calculated width results in a summ of all widths of submenus. In my case it resulted in a bug.
Maybe this visiblity change should be moved into the 'each' section?
Here is what I have now:

opt.$menu.find('ul').andSelf().each(function(){
var $this = $(this);
$this.css({position: 'static', display: 'block'});
$this.width($this.css('position', 'absolute').width())
.css('position', 'static');
}).css({position: '', display: ''});

Not sure if it's correct and fixes a current issue also, because for some reason I find it difficult to fully understand this part of code and why do we really need to recalculate the width.

@rodneyrehm
Copy link
Contributor

Please use this JSBin Template to provide a test case allowing me to reproduce your problem

@AAverin
Copy link

AAverin commented Dec 5, 2012

Done. Adding a custom icon for the arrow results in placement of that icon at 'min-width', but after that menu root mistically enlarges itself to the size that's more then min-width.

@rodneyrehm
Copy link
Contributor

Your arrow-image would be at the right side if you used background-position: 100% 2px;. Also, you should probably remove the following rule from contextMenu.css:

.context-menu-submenu:after {
    content: ">";
    color: #666;
    position: absolute;
    top: 0;
    right: 3px;
    z-index: 1;
}

aside from that I've fixed the problem locally. It will be included in the next release (around Christmas)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants