Skip to content

Registered CustomKey listeners are lost on reattach #92

@javier-godoy

Description

@javier-godoy

Describe the bug

A custom key listener is two-fold: there is a CustomKey DOM-event listener, and a client-side registration that filters which keys dispatch an event.

Registration r = getElement().addEventListener("CustomKey", listener).setFilter(filter);
executeJs("this.registerCustomKeyListener($0)", json);

The CustomKey event listener is added through Element API (so it is preserved after on reattach). However, the client side part (registerCustomKeyListener, etc) is added through JavaScript, and will be lost.

Expected behavior

Custom key listeners should after reattach.

Minimal reproducible example

@PreserveOnRefresh
public class ConsoleView extends Div {{
   XTerm xterm = new XTerm();
   TerminalHistory.extend(xterm);
   add(xterm);
}}
  1. Navigate to the view
  2. Write stuff and check that history works
  3. Press F5
  4. Check that history does not work

Add-on Version

3.0.0

Vaadin Version

24.4.6

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    To Do

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions