Skip to content

Commit

Permalink
Prevent subsequent v press from submitting form
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonmcook committed Jun 10, 2024
1 parent ee6ccb3 commit 98a6856
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion assets/js/keyboard-shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function addEventListeners () {

function handleKeyDown (event) {
if (state.shortcutBeingPressed) { return }
if (event.target.matches('input, textarea')) { return }
if (event.target.matches('input, select, textarea')) { return }

const matchingShortcut = keyboardShortcuts.find(shortcut => {
if (shortcut.hasModifier) {
Expand Down
8 changes: 8 additions & 0 deletions assets/js/sidebar/sidebar-version-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ export function openVersionSelect () {
if (select) {
select.focus()

// Prevent subsequent 'v' press from submitting form
select.addEventListener('keydown', event => {
if (event.key === 'Escape' || event.key === 'v') {
event.preventDefault()
select.blur()
}
})

if (navigator.userActivation.isActive && 'showPicker' in HTMLSelectElement.prototype) {
select.showPicker()
}
Expand Down

0 comments on commit 98a6856

Please sign in to comment.