Parcourir la source

Merge pull request #1431 from Siykt/fix/in-debugger-mode-clear-value

Fix: in debugger mode clear value
Ahmad Kholid il y a 1 an
Parent
commit
0ebe1b7ddb
1 fichiers modifiés avec 15 ajouts et 0 suppressions
  1. 15 0
      src/content/blocksHandler/handlerForms.js

+ 15 - 0
src/content/blocksHandler/handlerForms.js

@@ -26,6 +26,21 @@ async function forms(block) {
     if (block.debugMode && data.type === 'text-field') {
       element.focus?.();
 
+      if (data.clearValue) {
+        const backspaceCommands = new Array(element.value?.length ?? 0).fill({
+          type: 'rawKeyDown',
+          unmodifiedText: 'Delete',
+          text: 'Delete',
+          windowsVirtualKeyCode: 46,
+        });
+
+        await sendMessage(
+          'debugger:type',
+          { commands: backspaceCommands, tabId: block.activeTabId, delay: 0 },
+          'background'
+        );
+      }
+
       const commands = data.value.split('').map((char) => ({
         type: 'keyDown',
         text: char === '\n' ? '\r' : char,