ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

Link: Unable to activate Link through ENTER key press

Open 2bno1 opened this issue 5 years ago • 6 comments

Describe the bug Per document, onClick should be "Fired when the Link is triggered either with a mouse/tap or by using the Enter key." However, onClick is not called by using Enter Key when it's focused.

Isolated Example https://codesandbox.io/s/sad-faraday-voiil?file=/src/App.js

To Reproduce Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/sad-faraday-voiil?file=/src/App.js
  2. Press Tab key to focus on the Link: 'Focus me and press Enter'
  3. Press Enter key
  4. The onClick is not fired

Expected behavior The onClick of the Link component should be fired by pressing Enter key

Screenshots If applicable, add screenshots to help explain your problem.

UI5 Web Components for React Information @ui5/webcomponents version: 0.29.8 (@sf) @ui5/webcomponents-react version: 0.129.8 (@sf) Operating System: macOS Version 11.2.3 Browser: Chrome Version 89.0.4389.90

Additional context N/A

2bno1 avatar Mar 24 '21 03:03 2bno1

Hi @2bno1

you need to add the corresponding key event for this to work. Example

Lukas742 avatar Mar 24 '21 07:03 Lukas742

Hey @2bno1,

I'm not 100% sure whether the ui5-link should fire the onClick event after pressing the Enter key, so I'll forward this issue to the UI5 Web Components Repo for further investigation.

MarcusNotheis avatar Mar 24 '21 08:03 MarcusNotheis

Hi guys,

As you can read in our docs, the ui5-link should fire click event either with a mouse/tap or by using the Enter key. Moreover, you can try to add click eventlistener to any of the links on the page and you can observe that the event is actually thrown.

fifoosid avatar Mar 24 '21 09:03 fifoosid

Looks like this is somehow connected to the presence of the href attribute: https://codesandbox.io/s/nice-rhodes-508hc?file=/src/App.js

MarcusNotheis avatar Mar 24 '21 09:03 MarcusNotheis

Hi @2bno1

you need to add the corresponding key event for this to work. Example

@Lukas742 Thanks, the example works. However, as ENTER key press is the standard keyboard activation key for links. Is there any plan to enhance this ui5-link component to handle ENTER key internally?

2bno1 avatar Mar 25 '21 01:03 2bno1

Hello @SAP/ui5-webcomponents-topic-b @tsanislavgatev

Could you take over this issue?

The ui5-link does not fire the "click" event on pressing the Enter key. The openui5 Link, for reference is firing its "press" event on Enter (even if "href" is not present), so I guess we have to fix this to make the web component behaves the same as the openui5 Link.

The author has provided an isolated example and steps to reproduce.

ilhan007 avatar Jun 01 '21 13:06 ilhan007