-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove deprecated KeyboardEvent
properties from the Exit this Page component
#4813
Merged
Conversation
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
36degrees
changed the title
Remove deprecated KeyboardEvent properties in Exit this Page
Remove deprecated Mar 1, 2024
KeyboardEvent
properties from the Exit this Page component
📋 StatsFile sizes
Modules
View stats and visualisations on the review app Action run for 1b9ecf3 |
JavaScript changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.js b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.js
index b85c7040f..32ea76aa4 100644
--- a/packages/govuk-frontend/dist/govuk/govuk-frontend.min.js
+++ b/packages/govuk-frontend/dist/govuk/govuk-frontend.min.js
@@ -659,7 +659,7 @@ class ExitThisPage extends GOVUKFrontendComponent {
t.preventDefault(), this.exitPage()
}
handleKeypress(t) {
- this.$updateSpan && ("Shift" !== t.key && 16 !== t.keyCode && 16 !== t.which || this.lastKeyWasModified ? this.keypressTimeoutId && this.resetKeypressTimer() : (this.keypressCounter += 1, this.updateIndicator(), this.timeoutMessageId && (window.clearTimeout(this.timeoutMessageId), this.timeoutMessageId = null), this.keypressCounter >= 3 ? (this.keypressCounter = 0, this.keypressTimeoutId && (window.clearTimeout(this.keypressTimeoutId), this.keypressTimeoutId = null), this.exitPage()) : 1 === this.keypressCounter ? this.$updateSpan.textContent = this.i18n.t("pressTwoMoreTimes") : this.$updateSpan.textContent = this.i18n.t("pressOneMoreTime"), this.setKeypressTimer()), this.lastKeyWasModified = t.shiftKey)
+ this.$updateSpan && ("Shift" !== t.key || this.lastKeyWasModified ? this.keypressTimeoutId && this.resetKeypressTimer() : (this.keypressCounter += 1, this.updateIndicator(), this.timeoutMessageId && (window.clearTimeout(this.timeoutMessageId), this.timeoutMessageId = null), this.keypressCounter >= 3 ? (this.keypressCounter = 0, this.keypressTimeoutId && (window.clearTimeout(this.keypressTimeoutId), this.keypressTimeoutId = null), this.exitPage()) : 1 === this.keypressCounter ? this.$updateSpan.textContent = this.i18n.t("pressTwoMoreTimes") : this.$updateSpan.textContent = this.i18n.t("pressOneMoreTime"), this.setKeypressTimer()), this.lastKeyWasModified = t.shiftKey)
}
setKeypressTimer() {
this.keypressTimeoutId && window.clearTimeout(this.keypressTimeoutId), this.keypressTimeoutId = window.setTimeout(this.resetKeypressTimer.bind(this), this.timeoutTime)
Action run for 1b9ecf3 |
Other changes to npm packagediff --git a/packages/govuk-frontend/dist/govuk/all.bundle.js b/packages/govuk-frontend/dist/govuk/all.bundle.js
index 51f0fc054..319a2fe70 100644
--- a/packages/govuk-frontend/dist/govuk/all.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/all.bundle.js
@@ -1406,7 +1406,7 @@
if (!this.$updateSpan) {
return;
}
- if ((event.key === 'Shift' || event.keyCode === 16 || event.which === 16) && !this.lastKeyWasModified) {
+ if (event.key === 'Shift' && !this.lastKeyWasModified) {
this.keypressCounter += 1;
this.updateIndicator();
if (this.timeoutMessageId) {
diff --git a/packages/govuk-frontend/dist/govuk/all.bundle.mjs b/packages/govuk-frontend/dist/govuk/all.bundle.mjs
index 4bd2f966d..1e8dbc738 100644
--- a/packages/govuk-frontend/dist/govuk/all.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/all.bundle.mjs
@@ -1400,7 +1400,7 @@ class ExitThisPage extends GOVUKFrontendComponent {
if (!this.$updateSpan) {
return;
}
- if ((event.key === 'Shift' || event.keyCode === 16 || event.which === 16) && !this.lastKeyWasModified) {
+ if (event.key === 'Shift' && !this.lastKeyWasModified) {
this.keypressCounter += 1;
this.updateIndicator();
if (this.timeoutMessageId) {
diff --git a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js
index 5f4fde08a..4d726b847 100644
--- a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js
+++ b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js
@@ -435,7 +435,7 @@
if (!this.$updateSpan) {
return;
}
- if ((event.key === 'Shift' || event.keyCode === 16 || event.which === 16) && !this.lastKeyWasModified) {
+ if (event.key === 'Shift' && !this.lastKeyWasModified) {
this.keypressCounter += 1;
this.updateIndicator();
if (this.timeoutMessageId) {
diff --git a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs
index f0293f783..a8e072477 100644
--- a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs
@@ -429,7 +429,7 @@ class ExitThisPage extends GOVUKFrontendComponent {
if (!this.$updateSpan) {
return;
}
- if ((event.key === 'Shift' || event.keyCode === 16 || event.which === 16) && !this.lastKeyWasModified) {
+ if (event.key === 'Shift' && !this.lastKeyWasModified) {
this.keypressCounter += 1;
this.updateIndicator();
if (this.timeoutMessageId) {
diff --git a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs
index e81244c72..fa157c93e 100644
--- a/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs
+++ b/packages/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs
@@ -116,7 +116,7 @@ class ExitThisPage extends GOVUKFrontendComponent {
if (!this.$updateSpan) {
return;
}
- if ((event.key === 'Shift' || event.keyCode === 16 || event.which === 16) && !this.lastKeyWasModified) {
+ if (event.key === 'Shift' && !this.lastKeyWasModified) {
this.keypressCounter += 1;
this.updateIndicator();
if (this.timeoutMessageId) {
Action run for 1b9ecf3 |
36degrees
force-pushed
the
exit-this-page-keycode
branch
from
March 1, 2024 18:33
1065a7a
to
6b1abd0
Compare
36degrees
force-pushed
the
exit-this-page-keycode
branch
from
March 1, 2024 18:34
6b1abd0
to
1f768af
Compare
colinrotherham
approved these changes
Mar 4, 2024
`KeyboardEvent.keyCode` and `UIEvent.which` are both deprecated. `KeyboardEvent.key` is supported in all browsers that run our JavaScript, so we can safely remove the fallback references to these deprecated properties.
36degrees
force-pushed
the
exit-this-page-keycode
branch
from
March 4, 2024 13:50
1f768af
to
1b9ecf3
Compare
Merged
This was referenced Jun 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
KeyboardEvent.keyCode
andUIEvent.which
are both deprecated.KeyboardEvent.key
is supported in all browsers that run our JavaScript, so we can safely remove the fallback references to these deprecated properties.Part of #4709