Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Event delegation for #956 #971

Merged
merged 11 commits into from Nov 8, 2019
Merged

WIP Event delegation for #956 #971

merged 11 commits into from Nov 8, 2019

Conversation

sagalbot
Copy link
Owner

@sagalbot sagalbot commented Oct 25, 2019

  • adds a mapKeydown {Function} prop: receives an object and expects a returned object
  • adds selectOnKeyCodes {Array} prop: array of keycodes to trigger a typeahead select
  • allows for hooking into keydown events that are bound to the search input

mapKeydown is a high level function that maps keycodes to event handlers for the search input. It can be used to alter any default behavior.

selectOnKeyCodes is more of a shortcut prop, allowing you to choose what keyCodes should trigger a selection.

There's overlap between the two, but one is much more powerful than the other.

tag on space and comma with mapKeydown

<template>
  <v-select
    taggable
    multiple
    no-drop
    :map-keydown="handlers"
    placeholder="try tagging with space or comma to submit"
  />
</template>

<script>
export default {
  methods: {
    handlers (map, vm) {
      const createTag = e => {
        e.preventDefault();
        vm.typeAheadSelect();
        vm.searchEl.focus();
      };

      return {
        ...map, //  defaults
        32: createTag,  //  space
        188: createTag,  //  comma
      };
    },
  },
};
</script>

tag on space and comma with selectOnKeyCodes

<!-- select on tab, space, return, or comma -->
<v-select :selectOnKeyCodes="[9, 32, 13, 188]" /> 

Todo


Closes #956
Closes #377
Closes #502
Closes #847
Closes #900
Closes #849

@coveralls
Copy link

coveralls commented Oct 25, 2019

Coverage Status

Coverage increased (+0.2%) to 95.982% when pulling 1e6b0e9 on fix-956-event-delegation into ceb42b4 on master.

@sagalbot sagalbot self-assigned this Oct 26, 2019
@sagalbot sagalbot added this to the v3.3 milestone Oct 26, 2019
@sagalbot sagalbot marked this pull request as ready for review November 7, 2019 22:47
@Meekohi
Copy link

Meekohi commented Nov 8, 2019

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment