console: billing quantity boxes select their number on focus, so typing replaces the 0 (enhancement only)
Squashed from qty-select into main.
2 files changed,
+10
−2
internal/console/templates/billing.html+2 −2internal/console/templates/layout.html+8 −0
CI passed — run details
diff --git a/internal/console/templates/billing.html b/internal/console/templates/billing.html| index 8c73923dc..6e929249e 100644 |
| --- a/internal/console/templates/billing.html |
| +++ b/internal/console/templates/billing.html |
| @@ -87,7 +87,7 @@ |
| <table class="packs" aria-labelledby="packs-title"> |
| {{range .Packs}}<tr data-pack="{{.Name}}"> |
| <td><label for="pack-{{.Name}}">{{.Label}}</label>{{if .Adds}}<span class="small" id="pack-{{.Name}}-adds">{{.Adds}}</span>{{end}}</td> |
| - <td><input type="number" id="pack-{{.Name}}" name="pack_{{.Name}}" min="0" max="{{.Max}}" step="1" value="{{.Value}}" inputmode="numeric"{{if .Adds}} aria-describedby="pack-{{.Name}}-adds"{{end}}></td> |
| + <td><input type="number" id="pack-{{.Name}}" name="pack_{{.Name}}" min="0" max="{{.Max}}" step="1" value="{{.Value}}" inputmode="numeric" data-select{{if .Adds}} aria-describedby="pack-{{.Name}}-adds"{{end}}></td> |
| <td>{{range .Prices}}<span class="small price price-{{.Code}}" data-currency="{{.Code}}">{{.Text}}</span> |
| {{end}}</td> |
| </tr> |
| @@ -109,7 +109,7 @@ |
| <td><form method="post" action="{{$.Base}}/billing/change"> |
| <input type="hidden" name="csrf" value="{{$.CSRF}}"> |
| <input type="hidden" name="pack" value="{{.Name}}"> |
| - <input type="number" id="change-{{.Name}}" name="quantity" value="{{.Value}}" min="0" max="{{.Max}}" step="1" inputmode="numeric"{{if .Adds}} aria-describedby="change-{{.Name}}-adds"{{end}}> |
| + <input type="number" id="change-{{.Name}}" name="quantity" value="{{.Value}}" min="0" max="{{.Max}}" step="1" inputmode="numeric" data-select{{if .Adds}} aria-describedby="change-{{.Name}}-adds"{{end}}> |
| <button class="btn-sm btn-secondary" type="submit">{{billingText "button.change"}}</button> |
| </form></td> |
| </tr> |
diff --git a/internal/console/templates/layout.html b/internal/console/templates/layout.html| index de040377d..b8630b24e 100644 |
| --- a/internal/console/templates/layout.html |
| +++ b/internal/console/templates/layout.html |
| @@ -766,6 +766,14 @@ |
| f.submit(); |
| }, minBusy); |
| }); |
| + // A quantity box marked data-select selects its number when it gets |
| + // focus, so typing replaces the 0 instead of adding to it. |
| + document.addEventListener("focusin", function (e) { |
| + var t = e.target; |
| + if (t.matches && t.matches("input[data-select]")) { |
| + setTimeout(function () { t.select(); }, 0); |
| + } |
| + }); |
| // Coming back with the Back button restores the page from cache with the |
| // button still busy; give it back. |
| window.addEventListener("pageshow", function (e) { |