Bug 1693069 - Focus the page range field when choosing a custom print range. r=mstriemer

Differential Revision: https://phabricator.services.mozilla.com/D118886
This commit is contained in:
Matthew Noorenberghe 2021-07-05 22:55:55 +00:00
parent fde6550e6b
commit efc6383c93
2 changed files with 9 additions and 0 deletions

View File

@ -2274,6 +2274,9 @@ class PageRangeInput extends PrintUIControlMixin(HTMLElement) {
this._rangeInput.hidden = e.target.value == "all";
this.updatePageRange();
this.dispatchPageRange();
if (!this._rangeInput.hidden) {
this._rangeInput.select();
}
} else if (e.target == this._rangeInput) {
this._rangeInput.focus();
if (this._numPages) {

View File

@ -146,6 +146,7 @@ add_task(async function testPageRangeSets() {
await BrowserTestUtils.waitForAttributeRemoval("hidden", customRange);
ok(!customRange.hidden, "Custom range is showing");
is(helper.doc.activeElement, customRange, "Custom range field is focused");
// We need to set the input to something to ensure we do not return early
// out of our validation function
@ -279,6 +280,11 @@ add_task(async function testErrorClearedAfterSwitchingToAll() {
"Wait for range error to be hidden"
);
ok(customRange.hidden, "Custom range is hidden");
is(
helper.doc.activeElement,
helper.get("range-picker"),
"Range picker remains focused"
);
await helper.closeDialog();
});
});