Closed xmicore closed 3 years ago
An anchor in a menu item could not be controlled via the keyboard. A simple link in the menu is a bigger issue.
Sorry about the delay, our team has quite limited capacity at the moment.
In the meanwhile, I created a workaround that can be added to the project to monkey patch vaadin-item
:see_no_evil:
const ItemElement = customElements.get('vaadin-item');
if (ItemElement) {
// store the original method
const onKeyUp = ItemElement.prototype._onKeyup;
ItemElement.prototype._onKeyup = function(event) {
const item = Array.from(event.composedPath()).filter(el => el instanceof ItemElement)[0];
const willClick = item.hasAttribute('active');
// call the original method
onKeyUp.call(item, event);
if (willClick) {
const anchor = item.querySelector('a');
if (anchor) {
anchor.click();
}
}
};
}
This would need a unit test -- see the corresponding unit test for Tabs for inspiration: https://github.com/vaadin/vaadin-tabs/commit/b657fa235d86590fc39d690d5a6e848b9a8b7e97#diff-6fcdd3aebeb3be69481f063aaed32b8017c4a4a588cd01223e26ddb8d9a03da9
It has been a while since this PR was submitted. Apologies about keeping it open for so long without any progress. Please note, the new development for Vaadin web components will happen in the monorepo.
I'm closing this now. We will submit a new PR to the monorepo when the linked issue is prioritised.
This pull request resolves #279.