Skip to content

Commit

Permalink
fix: make clicks on type('{enter}') composed
Browse files Browse the repository at this point in the history
  • Loading branch information
kgroat committed Apr 2, 2023
1 parent 1c385e0 commit 70af6f1
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions packages/driver/cypress/e2e/commands/actions/type_events_spec.js
Original file line number Diff line number Diff line change
@@ -649,6 +649,19 @@ describe('src/cy/commands/actions/type - #type events', () => {
})
})
})

describe('shadow dom', () => {
// https://github.com/cypress-io/cypress/issues/26392
it('propagates through shadow roots', () => {
cy.visit('fixtures/shadow-dom-button.html')

cy.get('cy-test-element').invoke('on', 'click', cy.spy().as('clickSpy'))

cy.get('cy-test-element').shadow().find('button').focus().type('{enter}')

cy.get('@clickSpy').should('have.been.called')
})
})
})

describe(`type(' ') fires click event on button-like elements`, () => {
2 changes: 1 addition & 1 deletion packages/driver/src/cy/commands/actions/type.ts
Original file line number Diff line number Diff line change
@@ -294,7 +294,7 @@ export default function (Commands, Cypress, cy, state, config) {

const fireClickEvent = (el) => {
const ctor = $dom.getDocumentFromElement(el).defaultView!.PointerEvent
const event = new ctor('click')
const event = new ctor('click', { composed: true })

el.dispatchEvent(event)
}

0 comments on commit 70af6f1

Please sign in to comment.