vaadin / vaadin/framework

Same Shortcut for multiple Components is not possible

Open
#10,417 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement workaround
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

When adding the same Shortcut-KeyCode to multiple Components its not possible to trigger the ShortcutActions individually e.g when the Component is focused.

When pressing the Shortcut only the ShortcutAction that was registered first is executed.

 textfield.addShortcutListener(new ShortcutListener("textfieldShortcut", ShortcutAction.KeyCode.SPACEBAR, null)
    {
      @Override
      public void handleAction(Object pO, Object pO1)
      {
        System.out.println("textfield shortcut");
      }
    });

    grid.addShortcutListener(new ShortcutListener("gridShortcut", ShortcutAction.KeyCode.SPACEBAR, null)
    {
      @Override
      public void handleAction(Object pO, Object pO1)
      {
        System.out.println("grid shortcut");
      }
    });

In the example Code above only the Textfield ShortcutAction is executed regardless of which Component is focused.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example with two components registering SPACEBAR ShortcutListeners, then trace how shortcut listeners are registered and selected for the focused component. Done means the focused component's ShortcutAction runs instead of always running the listener registered first.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.