-
Notifications
You must be signed in to change notification settings - Fork 725
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5819 from mikeconley/fix-step1-a11y
Improve accessibility of switching-devices wizard step 1 autofocus behaviour.
- Loading branch information
Showing
7 changed files
with
92 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ export class SignInStep extends BaseFormStep { | |
<label for="email">${gettext("Enter your email")}</label> | ||
<div class="tooltip-container"> | ||
<aside id="email-error" class="tooltip">${gettext("Valid email required")}</aside> | ||
<input id="email" name="email" type="email" required="true" placeholder="${gettext("[email protected]")}"/> | ||
<input id="email" name="email" type="email" required="true" placeholder="${gettext("[email protected]")}" pending-autofocus="" /> | ||
</div> | ||
<button id="continue" class="mzp-c-button mzp-t-product" type="submit" data-event-category="device-migration-wizard" data-event-action="click">${gettext("Continue")}</button> | ||
|
@@ -69,7 +69,6 @@ export class SignInStep extends BaseFormStep { | |
this.#formEl.addEventListener("submit", this); | ||
this.#emailEl.addEventListener("blur", this); | ||
this.#emailEl.addEventListener("input", this); | ||
this.#emailEl.focus(); | ||
} | ||
|
||
disconnectedCallback() { | ||
|
@@ -169,6 +168,18 @@ export class SignInStep extends BaseFormStep { | |
} | ||
} | ||
|
||
// If we've reached the point where we've got hasUpdatedFxAState set true, | ||
// this means that we've confirmed that we're running on a non-disqualified | ||
// version of Firefox Desktop. If focus hasn't moved anywhere else in the | ||
// meantime, we'll move focus to the email field if it's never been moved | ||
// there before. | ||
if (this.state.hasUpdatedFxAState && this.#emailEl.hasAttribute("pending-autofocus")) { | ||
this.#emailEl.removeAttribute("pending-autofocus"); | ||
if (document.activeElement == document.body) { | ||
this.#emailEl.focus(); | ||
} | ||
} | ||
|
||
let alternativeLinks = this.shadowRoot.querySelectorAll(".alternative-link"); | ||
for (let link of alternativeLinks) { | ||
link.href = this.state.linkHref; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -386,6 +386,7 @@ describe("k", () => { | |
context: "fx_desktop_v3", | ||
redirect_to: window.location.href, | ||
redirect_immediately: true, | ||
hasUpdatedFxAState: true, | ||
}); | ||
}); | ||
|
||
|
@@ -418,6 +419,7 @@ describe("k", () => { | |
sumoEmail: "[email protected]", | ||
syncEnabled: false, | ||
confirmedSyncChoices: false, | ||
hasUpdatedFxAState: true, | ||
}; | ||
const EXPECTED_PAYLOAD = { | ||
service: "sync", | ||
|
@@ -436,14 +438,17 @@ describe("k", () => { | |
redirect_to: window.location.href, | ||
redirect_immediately: true, | ||
linkHref: `${FAKE_FXA_ROOT}?service=sync&action=email&utm_source=support.mozilla.org&utm_campaign=migration&utm_medium=mozilla-websites&entrypoint=fx-new-device-sync&entrypoint_experiment=experiment&entrypoint_variation=variation&flow_id=${FAKE_FXA_FLOW_ID}&flow_begin_time=${FAKE_FXA_FLOW_BEGIN_TIME}&context=fx_desktop_v3&redirect_to=https%3A%2F%2Fexample.com%2F%23search&redirect_immediately=true`, | ||
hasUpdatedFxAState: true, | ||
}; | ||
expect(step.enter(TEST_STATE)).to.deep.equal(EXPECTED_PAYLOAD); | ||
}); | ||
|
||
it("should send the user to the configure-sync step immediately if UITour says that the user is signed in", async () => { | ||
let setStepCalled = new Promise((resolve) => { | ||
gSetStepStub.callsFake((name, payload) => { | ||
resolve({ name, payload }); | ||
if (name == "configure-sync") { | ||
resolve({ name, payload }); | ||
} | ||
}); | ||
}); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters