mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-01-20 16:50:28 -05:00
Prevent prefix continuation if currently a text expander popup is open
This fixes that mentions and emoji autocompletion was broken in e.g. a
list, because the list handling take presidency over the text expansion.
(cherry picked from commit 276ef10dd5
)
This commit is contained in:
parent
28db11f2e7
commit
627634a76e
2 changed files with 28 additions and 0 deletions
|
@ -224,3 +224,29 @@ test('markdown insert table', async ({page}) => {
|
|||
await expect(textarea).toHaveValue('| Header | Header |\n|---------|---------|\n| Content | Content |\n| Content | Content |\n| Content | Content |\n');
|
||||
await save_visual(page);
|
||||
});
|
||||
|
||||
test('text expander has higher prio then prefix continuation', async ({page}) => {
|
||||
const response = await page.goto('/user2/repo1/issues/new');
|
||||
expect(response?.status()).toBe(200);
|
||||
|
||||
const textarea = page.locator('textarea[name=content]');
|
||||
const initText = `* first`;
|
||||
await textarea.fill(initText);
|
||||
await textarea.evaluate((it:HTMLTextAreaElement) => it.setSelectionRange(it.value.indexOf('rst'), it.value.indexOf('rst')));
|
||||
await textarea.press('End');
|
||||
|
||||
// Test emoji completion
|
||||
await textarea.press('Enter');
|
||||
await textarea.pressSequentially(':smile_c');
|
||||
await textarea.press('Enter');
|
||||
await expect(textarea).toHaveValue(`* first\n* 😸`);
|
||||
|
||||
// Test username completion
|
||||
await textarea.press('Enter');
|
||||
await textarea.pressSequentially('@user');
|
||||
await textarea.press('Enter');
|
||||
await expect(textarea).toHaveValue(`* first\n* 😸\n* @user2 `);
|
||||
|
||||
await textarea.press('Enter');
|
||||
await expect(textarea).toHaveValue(`* first\n* 😸\n* @user2 \n* `);
|
||||
});
|
||||
|
|
|
@ -99,6 +99,8 @@ class ComboMarkdownEditor {
|
|||
e.target._shiftDown = true;
|
||||
}
|
||||
if (e.key === 'Enter' && !e.shiftKey && !e.ctrlKey && !e.altKey) {
|
||||
// Prevent special line break handling if currently a text expander popup is open
|
||||
if (this.textarea.hasAttribute('aria-expanded')) return;
|
||||
if (!this.breakLine()) return; // Nothing changed, let the default handler work.
|
||||
this.options?.onContentChanged?.(this, e);
|
||||
e.preventDefault();
|
||||
|
|
Loading…
Add table
Reference in a new issue