Skip to content

Commit f984e51

Browse files
author
Jordan Humphreys
committed
Fix hover state in Firefox for nav bar inputs.
1 parent ceb7e6a commit f984e51

File tree

2 files changed

+45
-9
lines changed

2 files changed

+45
-9
lines changed

test/navigation.html

+19-5
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,25 @@ <h4>Nav Bar</h4>
6161
<a href="#">Nav Item 2</a>
6262
<a href="#" class="flyout-toggle"><span> </span></a>
6363
<ul class="flyout">
64-
<li><a href="#">Sub Nav Item 1</a></li>
65-
<li><a href="#">Sub Nav Item 2</a></li>
66-
<li><a href="#">Sub Nav 3</a></li>
67-
<li><a href="#">Sub Nav 4</a></li>
68-
<li><a href="#">Sub Nav Item 5</a></li>
64+
<li>
65+
<form action="#" method="post">
66+
<fieldset class="textbox">
67+
<label>
68+
<span>Username or email</span>
69+
<input type="text" name="username" autocomplete="on">
70+
</label>
71+
<label>
72+
<span>Password</span>
73+
<input class="js-password-field" type="password" value="" name="password">
74+
</label>
75+
<label>
76+
<input type="checkbox" value="1" name="remember_me">
77+
<span>Remember me</span>
78+
</label>
79+
<button type="submit" class="nice button" style="margin-bottom: 10px;">Sign in</button>
80+
</fieldset>
81+
</form>
82+
</li>
6983
</ul>
7084
</li>
7185
<li class="has-flyout">

vendor/assets/javascripts/foundation/jquery.foundation.navigation.js

+26-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,32 @@
1919
});
2020
$('.nav-bar>li.has-flyout', this).addClass('is-touch');
2121
} else {
22-
$('.nav-bar>li.has-flyout', this).hover(function () {
23-
$(this).children('.flyout').show();
24-
}, function () {
25-
$(this).children('.flyout').hide();
22+
$('.nav-bar>li.has-flyout', this).on('mouseenter mouseleave', function (e) {
23+
if (e.type == 'mouseenter') {
24+
$(this).children('.flyout').show();
25+
}
26+
27+
if (e.type == 'mouseleave') {
28+
var flyout = $(this).children('.flyout'),
29+
inputs = flyout.find('input'),
30+
hasFocus = function (inputs) {
31+
var focus;
32+
if (inputs.length > 0) {
33+
inputs.each(function () {
34+
if ($(this).is(":focus")) {
35+
focus = true;
36+
}
37+
});
38+
return focus;
39+
}
40+
41+
return false;
42+
};
43+
44+
if (!hasFocus(inputs)) {
45+
$(this).children('.flyout').hide();
46+
}
47+
}
2648
});
2749
}
2850

0 commit comments

Comments
 (0)