diff --git a/semcore/bulk-textarea/__tests__/bulk-textarea.browser-test.tsx b/semcore/bulk-textarea/__tests__/bulk-textarea.browser-test.tsx index 98cf1f711d..246c8fa25a 100644 --- a/semcore/bulk-textarea/__tests__/bulk-textarea.browser-test.tsx +++ b/semcore/bulk-textarea/__tests__/bulk-textarea.browser-test.tsx @@ -680,9 +680,7 @@ test.describe(`${TAG.FUNCTIONAL}`, () => { expect(lineCount).toBe(2); await expect(locators.counter(page)).toHaveText('1/10of 10 lines'); - const firstLineText = await locators.row(page, 0).textContent(); - - expect(firstLineText).not.toMatch(/^http:\/\//); + await expect(locators.row(page, 0)).not.toHaveText(/^http:\/\//); await locators.button(page, 'Clear all').click(); await page.waitForTimeout(100); diff --git a/semcore/bulk-textarea/src/BulkTextarea.tsx b/semcore/bulk-textarea/src/BulkTextarea.tsx index 1c334d3653..3aefad3a27 100644 --- a/semcore/bulk-textarea/src/BulkTextarea.tsx +++ b/semcore/bulk-textarea/src/BulkTextarea.tsx @@ -234,6 +234,14 @@ class BulkTextareaRoot extends Component< this.handlers.showErrors(false); this.handlers.errors([]); this.handlers.state('normal'); + + if (document.activeElement === this.clearAllButtonRef.current) { + const textarea = this.inputFieldRef.current?.querySelector('[role="textbox"]'); + + if (textarea instanceof HTMLDivElement) { + textarea.focus(); + } + } } }; @@ -241,15 +249,9 @@ class BulkTextareaRoot extends Component< this.handlers.showErrors(false); this.handlers.errors([]); this.setState({ errorIndex: -1 }); - // @ts-ignore - this.handlers.value('', e); + // @ts-ignore (we should set right type of value depending on the type of value passed) + this.handlers.value(typeof this.asProps.value === 'string' ? '' : [], e); this.handlers.state('normal'); - - const textarea = this.inputFieldRef.current?.querySelector('[role="textbox"]'); - - if (textarea instanceof HTMLDivElement) { - textarea.focus(); - } }; handleChangeErrorIndex = (amount: number) => () => { diff --git a/semcore/bulk-textarea/src/components/InputField/InputField.tsx b/semcore/bulk-textarea/src/components/InputField/InputField.tsx index 35c29dcbd8..3d086c8a21 100644 --- a/semcore/bulk-textarea/src/components/InputField/InputField.tsx +++ b/semcore/bulk-textarea/src/components/InputField/InputField.tsx @@ -218,7 +218,11 @@ class InputField extends Component< if (paragraph instanceof HTMLParagraphElement) { if (newValue === '') { - paragraph.innerHTML = this.emptyLineValue; + if (lines.length === 1) { + this.textarea.textContent = ''; + } else { + paragraph.innerHTML = this.emptyLineValue; + } } else { paragraph.replaceChild(newValueTextNode, paragraph.childNodes.item(0)); } @@ -638,7 +642,9 @@ class InputField extends Component< onBlur(valueToChange as T, event); setTimeout(() => { - this.setState({ keyboardLineIndex: -1 }); + if (document.activeElement !== this.textarea) { + this.setState({ keyboardLineIndex: -1 }); + } }, 200); } diff --git a/semcore/dropdown-menu/src/DropdownMenu.jsx b/semcore/dropdown-menu/src/DropdownMenu.jsx index 0b2775aa5a..8c3b7498fe 100644 --- a/semcore/dropdown-menu/src/DropdownMenu.jsx +++ b/semcore/dropdown-menu/src/DropdownMenu.jsx @@ -332,7 +332,9 @@ function List({ styles, Children }) { const SScrollContainer = ScrollAreaComponent.Container; const preventFocusByClick = React.useCallback((e) => { - e.preventDefault(); + if (!e.target.draggable) { + e.preventDefault(); + } }, []); return sstyled(styles)(