react-hotkeys icon indicating copy to clipboard operation
react-hotkeys copied to clipboard

[BUG] Text input gets populated with the ketMap sequence keys

Open MarioKrstevski opened this issue 5 years ago • 1 comments

Describe the bug I have an action happening on space+b but never the less, any other combination acts the same. In my case, I need to select and focus a text input and make it available to start typing, but the letter 'b' gets typed into the input.

Not really sure if it is a bug, but I tried to search for a fix/right approach, but couldn't find one. IF a solution exist please point it out.

How are you using react hotkeys components? (HotKeys, GlobalHotKeys, IgnoreKeys, etc)

   const keyMap = {
        FOCUS_BARCODE_INPUT: 'b+space',
    }

    const keyMapHandlers = {
        FOCUS_BARCODE_INPUT: () => {
            document.getElementById('barcode-input-field').focus()
            // Code for Toast message to appear, indicating we are in typing mode and they can type/scan barcodes 
    }
  <HotKeys
                keyMap={keyMap}
                handlers={keyMapHandlers}
            >
 <App> ... </App>
</Hotkeys>

Expected behavior I don't want this behavior. I just want the trigger sequence to not be used as my new input

Platform (please complete the following information):

  • Version of react-hotkeys
  • Browser [e.g. chrome, safari]
  • OS: [e.g. iOS]

Are you willing and able to create a PR request to fix this issue? No Include the smallest log that includes your issue:

Set logging to verbose (you'll need the development build if its possible):

import { configure } from 'react-hotkeys';

configure({
  logLevel: 'verbose'
})

What Configuration options are you using?

configure({
  //options
})

MarioKrstevski avatar Feb 03 '20 15:02 MarioKrstevski

@MarioKrstevski you need to cancel event in order to prevent input, i.e

const keyMapHandlers = {
  FOCUS_BARCODE_INPUT: (event) => {
    event.preventDefault();
    document.getElementById('barcode-input-field').focus()
  }
}

This is not a bug, that's intended behavior.

MasterLambaster avatar Mar 27 '20 11:03 MasterLambaster