mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-21 14:41:00 -06:00
Merge pull request #20375 from majidzeno/issue-20222
fix: shortcuts conflict with browser native shortcuts
This commit is contained in:
@@ -821,6 +821,7 @@ describe('Settings', () => {
|
||||
it('loads preferred editor, available editors and shows spinner', () => {
|
||||
cy.get('.loading-editors').then(function () {
|
||||
expect(this.ipc.getUserEditor).to.be.called
|
||||
cy.contains('File Opener Preference').click()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -135,5 +135,15 @@ describe('shortcuts', function () {
|
||||
cy.get('button.stop').trigger('mouseover')
|
||||
cy.get('.cy-tooltip').should('have.text', 'Stop Running S')
|
||||
})
|
||||
|
||||
it('does not run shortcut if modifier keys are pressed', () => {
|
||||
['{ctrl+f}', '{alt+f}', '{shift+f}', '{meta+f}'].forEach((text) => {
|
||||
cy.get('body').type(text)
|
||||
})
|
||||
|
||||
cy.then(() => {
|
||||
expect(runner.emit).not.to.have.been.calledWith('focus:tests')
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// @ts-ignore
|
||||
import dom from '@packages/driver/src/dom'
|
||||
import $dom from '@packages/driver/src/dom'
|
||||
import events from './events'
|
||||
import appState from './app-state'
|
||||
import { action } from 'mobx'
|
||||
@@ -16,7 +16,10 @@ class Shortcuts {
|
||||
_handleKeyDownEvent (event: KeyboardEvent) {
|
||||
// if typing into an input, textarea, etc, don't trigger any shortcuts
|
||||
// @ts-ignore
|
||||
if (dom.isTextLike(event.target)) return
|
||||
const isTextLike = $dom.isTextLike(event.target)
|
||||
const isAnyModifierKeyPressed = event.altKey || event.ctrlKey || event.shiftKey || event.metaKey
|
||||
|
||||
if (isAnyModifierKeyPressed || isTextLike) return
|
||||
|
||||
switch (event.key) {
|
||||
case 'r': !appState.studioActive && events.emit('restart')
|
||||
|
||||
Reference in New Issue
Block a user