diff --git a/packages/driver/cypress/e2e/commands/actions/type.cy.js b/packages/driver/cypress/e2e/commands/actions/type.cy.js index 301f660b098e..01cc7298adf4 100644 --- a/packages/driver/cypress/e2e/commands/actions/type.cy.js +++ b/packages/driver/cypress/e2e/commands/actions/type.cy.js @@ -958,25 +958,6 @@ describe('src/cy/commands/actions/type - #type', () => { .should('have.value', 'baroo') }) - // WebKit will select all input content on focus. This causes our - // cursor placement logic to be ignored, as we interpret the default - // selection as a user-provided selection that we do not want to override. - // We work around this by preventing the default selection on focus using - // our own capture-phase 'focus' event handler; this test ensures that user-set - // capture-phase events continue to function as expected for the purpose - // of selection updates. - it('respects changed selection in focus handler during capture phase', () => { - cy.get('#input-without-value') - .then(($el) => { - $el.val('foo') - $el.get(0).addEventListener('focus', (e) => { - e.currentTarget.setSelectionRange(0, 1) - }, { capture: true }) - }) - .type('bar') - .should('have.value', 'baroo') - }) - it('overwrites text when selectAll in mouseup handler', () => { cy.$$('#input-without-value').val('0').mouseup(function () { $(this).select() diff --git a/packages/driver/src/cy/focused.ts b/packages/driver/src/cy/focused.ts index 2a685acd46a1..d20f9e61475d 100644 --- a/packages/driver/src/cy/focused.ts +++ b/packages/driver/src/cy/focused.ts @@ -144,9 +144,9 @@ export const create = (state: StateFunc) => ({ // and persist it, leaving the selection contents to be overwritten rather than appended to // on subsequent actions. // - // In order to avoid this behavior, we explicitly set the selection range with the current - // selectionStart/selectionEnd values. This will bypass the default select-all behavior, even though - // logically it looks like a no-op. + // To avoid this behavior, we explicitly set the selection range with the current + // selectionStart/selectionEnd values prior to calling focus. This will bypass the + // default select-all behavior even though logically it looks like a no-op. try { el.setSelectionRange(el.selectionStart, el.selectionEnd) } catch (e) {