Managed to create a simpler way using the contenteditable
attribute. Right now it isn't visually similar to Google's input, but there are no obstacles for that. In functionality, it works as you expect: Auto resize with minimum width, editable, but doesn't seem so when not hovered and handles "saving" when left.
$(".google").blur(function(evt) {
//Insert real saving logic here.
console.log("Save things!");
});
* {
box-sizing: border-box;
}
.google {
display: inline-block;
height: 25px;
line-height: 25px;
width: auto;
border: none;
min-width: 80px;
font-family: sans-serif;
}
.google:hover, .google:focus, .google:active {
border: 1px solid gray;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="google" size="1" contenteditable="true">Hello</div>
It doesn't actually need jQuery, it is only used for the blur
handler.