diff --git a/toolkit/components/printing/content/print.js b/toolkit/components/printing/content/print.js index 1d1c0ae90d9f..ba7b7054aaf6 100644 --- a/toolkit/components/printing/content/print.js +++ b/toolkit/components/printing/content/print.js @@ -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) { diff --git a/toolkit/components/printing/tests/browser_print_page_range.js b/toolkit/components/printing/tests/browser_print_page_range.js index d5d64262c02e..9f6aea764ff4 100644 --- a/toolkit/components/printing/tests/browser_print_page_range.js +++ b/toolkit/components/printing/tests/browser_print_page_range.js @@ -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(); }); });