mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-08 09:01:03 -08:00
fix(video-player): ignore hotkeys when typing in search input
Prevent global hotkeys from triggering while the user is typing in input or textarea fields. Add a private isTypingInInput(event) helper and short-circuit key handlers (info key and digit keys) to return early when the event target is an input or textarea. This avoids interfering with normal text entry (e.g., entering numbers in forms) and prevents accidental overlay toggles or channel changes while the user is focused on a form field.
This commit is contained in:
1 parent
8482e7c76a
commit
c2c06a99be
1 file changed
+21
@@ -368,6 +368,10 @@ export class VideoPlayerComponent implements OnInit {
|
||||
*/
|
||||
@HostListener('document:keydown.i', ['$event'])
|
||||
handleInfoKeyPress(event: Event): void {
|
||||
// Don't trigger hotkeys when user is typing in input fields
|
||||
if (this.isTypingInInput(event)) {
|
||||
return;
|
||||
}
|
||||
// Prevent default behavior and show info overlay
|
||||
event.preventDefault();
|
||||
this.toggleInfoOverlay();
|
||||
@@ -380,6 +384,10 @@ export class VideoPlayerComponent implements OnInit {
|
||||
handleKeyPress(event: KeyboardEvent): void {
|
||||
// Only handle digit keys (0-9)
|
||||
if (event.key >= '0' && event.key <= '9') {
|
||||
// Don't trigger hotkeys when user is typing in input fields
|
||||
if (this.isTypingInInput(event)) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
this.handleChannelNumberInput(event.key);
|
||||
}
|
||||
@@ -453,4 +461,17 @@ export class VideoPlayerComponent implements OnInit {
|
||||
this.channelNumberTimeout = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the user is currently typing in an input or textarea field
|
||||
* @param event Keyboard event
|
||||
* @returns true if the event target is an input or textarea element
|
||||
*/
|
||||
private isTypingInInput(event: Event): boolean {
|
||||
const target = event.target;
|
||||
return (
|
||||
target instanceof HTMLInputElement ||
|
||||
target instanceof HTMLTextAreaElement
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user