To disable the keydown event for the PrimeNG component #1626
-
|
I want to disable keydown event for some components: dropdown, dynamic-dialog, contextmenu, button. Because I have a demo, if has more data, when I press some key (esc), the page will hang. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
I hope component can support config for disable/enable keyboard event on it. |
Beta Was this translation helpful? Give feedback.
-
|
Hi, It's not supported right now. However, we're implementing the passthrough and it'll be possible to override the component's keydown method. |
Beta Was this translation helpful? Give feedback.
-
|
If anyone like me just needs something hacky until a solution is ready, a simple directive works. My problem was that Accordions were eating Home/End key presses, which meant that The (admittingly brittle) fix was to just to overwrite the handlers that contained a call to @Directive({
selector: '[accordionHomeEndBypass]',
})
export class AccordionHomeEndBypassDirective {
constructor(
private accordion: Accordion,
) {
accordion.onTabHomeKey = (event) => {};
accordion.onTabEndKey = (event) => {};
}
}And then <p-accordion
accordionHomeEndBypass
>
<p-accordion-panel>
<p-accordion-header>Header</p-accordion-header>
<p-accordion-content>
<input pInputText />
</p-accordion-content>
</p-accordion-panel>
</p-accordion>And now the accordion won't prevent Home/End keys from working. Although, of course, this also disables the accordion-specific behavior tied to those keys. |
Beta Was this translation helpful? Give feedback.
Hi,
It's not supported right now. However, we're implementing the passthrough and it'll be possible to override the component's keydown method.