Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

submit button 'depressed' state on focus -- potential chrome bug?

What's with submit buttons in Chrome?

<input type='text' placeholder='Dummy Input'/>
<input type='submit'/>

The active 'depressed' state of the submit button will only occur if the button does not have focus. To reproduce, see this JSFiddle. In fact, the text-field isn't really even necessary, only to allow tab focus into the submit button.

So go ahead, place cursor in text field, press tab and click submit while the button is focused (orange). The event fires, but the button does not depress.

Pressing spacebar when focused instead of click will depress the button. (thx @Ineentho) What gives?

Note: I've submitted this to the Chrome Issue Tracker

like image 954
Jordan Arseno Avatar asked May 04 '13 08:05

Jordan Arseno


People also ask

Why is the submit button not working?

Why submit button is not working? Sometimes the problem is caused by old versions of the Javascript files, cached by your browser and can be fixed by clearing the browser cache. You can use the browser console of your browser for debugging.

How do I make an action button in HTML?

The <input type="submit"> defines a button for submitting the form data to a form-handler. The form-handler is typically a file on the server with a script for processing input data. The form-handler is specified in the form's action attribute.


1 Answers

You could use some javascript/jquery to un-focus the textbox on hover so the :active properties would be applied when clicked.

$("input[type=submit]").hover(function(){
     $(this).blur();
});

Also, you could apply css to the :focus pseudoclass, so the outline would always be invisible.

input[type=submit]:focus {outline:none;}

See this fiddle: http://jsfiddle.net/qahcJ/1/

UPDATE

I think that you can't solve this without Javascript hack, so here is a much simpler way to do it. Just use this piece of code:

$("input[type=submit]").bind("mousedown",function(e){
    return false;
});

Demo: http://jsfiddle.net/gFMTt/

like image 195
Szőke Péter Avatar answered Oct 11 '22 08:10

Szőke Péter