mtkopone / zelect

From <select> to something more 2012
Do What The F*ck You Want To Public License
395 stars 42 forks source link

Entering unmatched text collapses the control. #7

Closed mendeza closed 11 years ago

mendeza commented 11 years ago

zelect-collapsed

mtkopone commented 11 years ago

I'm sorry, but I'm going to need some more info to know what this is about?

mtkopone commented 11 years ago

This might be a browser issue? Which one we're you using?

Here's chrome:

screen shot 2013-05-15 at 9 27 05 am

ErtugKaya commented 11 years ago

Just press enter after that. It collapses for me too. Using latest Chrome.

Edit: It collapses because text inside div is gone.

brianmhunt commented 11 years ago

I can confirm that this behaviour occurs on Chrome on Mac, Chrome on iOS, and Safari on iOS.

brianmhunt commented 11 years ago

A selection of the trace of the issue when it exhibits is as follows:

It seems that the issue is the div collapsing because the text is set to empty ('').

There are three apparent workarounds: 1. putting a &nbsp; in the div whenever the content is blank, or 2. manually setting the height, or 3. adding a character in a <span> whose visibility is hidden to the div.

An example of fix 1 (probably the easiest) would be changing renderContext to:

$obj[htmlOrText(content)](content === '' ? "&nbsp;" : content);
return $obj;
function htmlOrText(x) {
      return (x instanceof jQuery || x.nodeType != null || x === '')
              ? 'html' : 'text'
}

This ensures that $obj.html("&nbsp;") is called when the content is the empty string.

There may be other and better workarounds, but this'll probably do the trick.

mtkopone commented 11 years ago

This should be fixed in 0.0.8.

Pressing enter really shouldn't have "made a selection" when there is no selection to be made... So I fixed this by doing nothing when listNavigator.current() doesn't hit anything...