CreateImageWizard: fix Enter key for packages search

The addEventListener call needs to have the useCapture field set to
true. The data-driven-forms patternfly 4 wizard will continue to the
next step when the Enter key is pressed. If we add our keydownHandler as
an event listener with useCapture set to True, the keydownHandler will
trigger before the wizards handler. This will effectively override the
wizard's handling of the Enter key so that it can be used to search when
the user has either package search bar in focus.
This commit is contained in:
Jacob Kozol 2021-11-20 22:00:36 +01:00 committed by jkozol
parent eac76a61eb
commit 940e40409c

View file

@ -107,10 +107,10 @@ const Packages = ({ defaultArch, ...props }) => {
};
useEffect(() => {
document.addEventListener('keydown', keydownHandler, false);
document.addEventListener('keydown', keydownHandler, true);
return () => {
document.removeEventListener('keydown', keydownHandler, false);
document.removeEventListener('keydown', keydownHandler, true);
};
});