mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
LibWeb: Don't move focus when setting input value
This commit is contained in:
parent
d29797f118
commit
1d9c404b8c
Notes:
github-actions[bot]
2024-09-12 09:46:32 +00:00
Author: https://github.com/Gingeh
Commit: 1d9c404b8c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1355
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/trflynn89
7 changed files with 59 additions and 26 deletions
|
@ -4,7 +4,7 @@
|
|||
text</textarea>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
asyncTest(async done => {
|
||||
let textInput = document.getElementById('text-input');
|
||||
let dateInput = document.getElementById('date-input');
|
||||
let textarea = document.getElementById('textarea');
|
||||
|
@ -26,21 +26,46 @@ text</textarea>
|
|||
println(`date input setting selectionStart error: ${e}`);
|
||||
}
|
||||
|
||||
textInput.addEventListener('select', e => println(`select event fired: ${e.target.selectionStart} ${e.target.selectionEnd}`))
|
||||
|
||||
textInput.addEventListener('select', e => println(`select event fired: ${e.target.selectionStart} ${e.target.selectionEnd}`));
|
||||
const waitForSelect = (element) => {
|
||||
return new Promise(resolve => {
|
||||
const handler = () => {
|
||||
element.removeEventListener('select', handler);
|
||||
resolve();
|
||||
};
|
||||
element.addEventListener('select', handler);
|
||||
});
|
||||
};
|
||||
|
||||
textInput.select();
|
||||
dumpSelection(textInput);
|
||||
textInput.setSelectionRange(2, 4, 'forward');
|
||||
dumpSelection(textInput);
|
||||
textInput.selectionStart = 1;
|
||||
dumpSelection(textInput);
|
||||
textInput.selectionEnd = 5;
|
||||
dumpSelection(textInput);
|
||||
textInput.selectionStart = 6;
|
||||
dumpSelection(textInput);
|
||||
textInput.selectionDirection = 'backward';
|
||||
await waitForSelect(textInput);
|
||||
dumpSelection(textInput);
|
||||
|
||||
textInput.setSelectionRange(2, 4, 'forward');
|
||||
await waitForSelect(textInput);
|
||||
dumpSelection(textInput);
|
||||
|
||||
textInput.selectionStart = 1;
|
||||
await waitForSelect(textInput);
|
||||
dumpSelection(textInput);
|
||||
|
||||
textInput.selectionEnd = 5;
|
||||
await waitForSelect(textInput);
|
||||
dumpSelection(textInput);
|
||||
|
||||
textInput.selectionStart = 6;
|
||||
await waitForSelect(textInput);
|
||||
dumpSelection(textInput);
|
||||
|
||||
textInput.selectionDirection = 'backward';
|
||||
await waitForSelect(textInput);
|
||||
dumpSelection(textInput);
|
||||
|
||||
textarea.addEventListener('select', e => {
|
||||
dumpSelection(textarea);
|
||||
done();
|
||||
});
|
||||
textarea.select();
|
||||
dumpSelection(textarea);
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue