XtermBlazor icon indicating copy to clipboard operation
XtermBlazor copied to clipboard

customKeyEventHandler is not invoked properly

Open Hastaroth1 opened this issue 2 years ago • 2 comments

First of all, thank you for this package.

Describe the bug

When using the customKeyEventHandler to intercept keys, the KeyBoardEvent object is not passed as a parameter as expected. Instead is it passed as the this:

image

image

I believe the issue is that call expects the first parameter to be the this context but it is called only with the KeyboardEvent

https://github.com/BattlefieldDuck/XtermBlazor/blob/main/XtermBlazor/src/index.ts#L47

image

I'm not sure what the this object is when Xtermjs calls the handler directly, but it would make sense to me to pass the terminal as the this.

To Reproduce Steps to reproduce the behavior:

  1. Create a terminal
  2. In OnFirstRender or some other lifecycle method, use terminal.SetCustomKeyEventHandler to set a custom key handler.
  3. Type anything inside the terminal
  4. The function called in SetCustomKeyEventHandler will have no param passed and instead the this object will contain the event information.

Expected behavior

The first function param should contain the KeyboardEvent object.

Desktop (please complete the following information):

  • OS: Windows
  • Browser: Edge (WebView2)
  • Version [e.g. 22

Hastaroth1 avatar Sep 05 '24 17:09 Hastaroth1

I've created a pull request but I have not tested the changes.

Let me know what you think.

Hastaroth1 avatar Sep 05 '24 17:09 Hastaroth1

Thanks @Hastaroth1! Great catch on the issue. I’ll review the pull request shortly.

BattlefieldDuck avatar Sep 17 '24 06:09 BattlefieldDuck