refactor: Remove deprecated keypress event handler and update keyup logic for better autocomplete behavior
This commit is contained in:
+14
-13
@@ -852,20 +852,21 @@ export class AutocompleteEventHandler {
|
||||
*/
|
||||
handleKeyUp(event){
|
||||
if (!settingValues.enabled || !autocompleteUI) return;
|
||||
|
||||
updateAutocompleteDisplay(event.target);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {KeyboardEvent} event
|
||||
* @returns
|
||||
*/
|
||||
handleKeyPress(event){
|
||||
if (!settingValues.enabled || !autocompleteUI) return;
|
||||
if (event.defaultPrevented) return; // Ignore if default action is prevented
|
||||
|
||||
updateAutocompleteDisplay(event.target);
|
||||
if (autocompleteUI.isVisible()) {
|
||||
switch (event.key) {
|
||||
case "Escape":
|
||||
event.preventDefault();
|
||||
autocompleteUI.hide();
|
||||
break;
|
||||
}
|
||||
} else if (event.key.length > 1 && event.key != "Delete" && event.key != "Backspace") {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.defaultPrevented) {
|
||||
updateAutocompleteDisplay(event.target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-6
@@ -20,7 +20,7 @@ function initializeEventHandlers() {
|
||||
element.addEventListener('blur', handleBlur);
|
||||
element.addEventListener('keydown', handleKeyDown);
|
||||
element.addEventListener('keyup', handleKeyUp);
|
||||
element.addEventListener('keypress', handleKeyPress);
|
||||
// element.addEventListener('keypress', handleKeyPress); // keypress is deprecated
|
||||
|
||||
// Add new event listeners for related tags feature
|
||||
element.addEventListener('mousemove', handleMouseMove);
|
||||
@@ -108,11 +108,6 @@ function initializeEventHandlers() {
|
||||
relatedTagsEventHandler.handleKeyUp(event);
|
||||
}
|
||||
|
||||
function handleKeyPress(event) {
|
||||
autocompleteEventHandler.handleKeyPress(event);
|
||||
relatedTagsEventHandler.handleKeyPress(event);
|
||||
}
|
||||
|
||||
// New event handler for mousemove to show related tags on hover
|
||||
function handleMouseMove(event) {
|
||||
autocompleteEventHandler.handleMouseMove(event);
|
||||
|
||||
@@ -656,14 +656,6 @@ export class RelatedTagsEventHandler {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {KeyboardEvent} event
|
||||
*/
|
||||
handleKeyPress(event){
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {MouseEvent} event
|
||||
|
||||
Reference in New Issue
Block a user