Git Product home page Git Product logo

Comments (7)

envex avatar envex commented on August 20, 2024 1

That did the trick, thanks!

from atom-keymap.

nathansobo avatar nathansobo commented on August 20, 2024

Interesting. We currently call preventDefault and stopPropagation to indicate that the keymap system has "consumed" the event by transforming it into the specified command, but I don't actually have a clear picture of exactly what would go wrong if we didn't do that. It's been a long time since that decision was made.

Could you explain the specifics of your situation? Do you have a proposal for how it would work?

from atom-keymap.

envex avatar envex commented on August 20, 2024

The example in this situation is I have a searchable item component. In that component is an input and a select dropdown (set to multiple so it acts/looks like a list).

Natively, once the select is focused, you can use the arrow keys to navigate through the list. You can see that functionality here: http://jsbin.com/geremameme/edit?html,output

I've setup a custom up (and down) key event so that if the input is focused, pressing the down arrow would focus the select.

With the key-map attaching the down event, the native down event is blocked and only the key-map down is fired.

Ideally it would be nice if I could either:

  • Tell key-map to not preventDefault()
  • Call a method inside my component that listens to the event, and tell key-map it's ok to bubble up.
// Badly coded example
window.addEventListener('up-event', (event) => {
  // Do something

  event.bubble();
});

from atom-keymap.

nathansobo avatar nathansobo commented on August 20, 2024

Could you map the up arrow to the special native! directive or use the .native-key-bindings class on your component and do your own event handling?

from atom-keymap.

envex avatar envex commented on August 20, 2024

Yeah, I'm just handling it natively for now. I was just curious if there was a way to use keymap for that event/situation.

from atom-keymap.

nathansobo avatar nathansobo commented on August 20, 2024

You can also call abortKeyBinding on the emitted command event to tell the keymap system that even though the binding matched and emitted a command, you still want to continue as if the key binding didn't match. This wouldn't prevent other bindings further up in the document from matching the event however. Does that address your issue?

from atom-keymap.

envex avatar envex commented on August 20, 2024

Interesting. That may be the key. Let me test it out and I'll get back to you.

Thanks!

from atom-keymap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.