Skip to content

Conversation

dobromir-hristov
Copy link
Contributor

@dobromir-hristov dobromir-hristov commented May 23, 2020

Description

This PR fixes an issue with Vue 3 handling modifiers and keyCodes.

It should now allow passing modifiers the same way as you would do with in Vue. Main fixes are general key modifiers and system key modifiers.

  • trigger('keydown.meta.shift.c') - will trigger a cmd + shift + c event listener.
  • trigger('keydown.13') - will trigger on enter only, because keyCode is no longer supported.
  • trigger('click.right') - will trigger a righclick contextmenu event.
  • trigger('click.middle') - will trigger a middle click event.

Context

While writing the docs for form handling I asked myself if we support trigger('keydown.enter') syntax, as I am sure we do in VTU 1, hence we have a dedicated test even - https://github.com/vuejs/vue-test-utils/blob/dev/test/specs/wrapper/trigger.spec.js#L73

However when I re-implemented the same test in VTU 2, it failed. I tried debugging, the trigger code is pretty much the same as VTU 1. I am not sure what is going on here :/

@dobromir-hristov
Copy link
Contributor Author

dobromir-hristov commented May 23, 2020

Ok well this is apparently keyCode is no longer supported in Vue - https://codepen.io/dobromir/pen/vYNPyPx?editors=1011

@dobromir-hristov dobromir-hristov changed the title Regression: trigger not working with dot notation modifiers Fix: trigger not working with some dot.notation modifiers May 23, 2020
Copy link
Member

@lmiller1990 lmiller1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code seems good, few random questions. did you find this when using VTU next in a project?

@dobromir-hristov
Copy link
Contributor Author

So I found the issue while prototyping the docs for form handling. We have complicated cases at work which I got inspired from to dig deeper.

The main issue was that Vue 3 did not seem to have keyCode anymore, so tests would fail with just eventStrings

@lmiller1990
Copy link
Member

Looks good to me. I'll approve, hit merge when you are happy.

@dobromir-hristov dobromir-hristov merged commit 7905fe6 into master May 24, 2020
@dobromir-hristov dobromir-hristov deleted the trigger-not-working-with-string-modifiers branch May 24, 2020 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants