Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execCommand is asynchronous? #21

Open
fregante opened this issue Apr 26, 2023 · 3 comments
Open

execCommand is asynchronous? #21

fregante opened this issue Apr 26, 2023 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@fregante
Copy link
Owner

See refined-github/refined-github#6348 (comment)

Maybe it's only Chromium. I wonder if reading field.value immediately after forces a synchronous update.

@fregante
Copy link
Owner Author

fregante added a commit that referenced this issue Feb 19, 2024
Potentially described in #21
@twschiller
Copy link

twschiller commented Feb 22, 2024

FWIW, Chromium's tests for insertText look synchronous: https://chromium.googlesource.com/chromium/blink.git/+/refs/heads/main/LayoutTests/editing/execCommand/insert-text-not-inheriting-block-properties.html

Presumably, an async focus would look something like (not sure what you're want "refocus" handling to be):

async focus(element, {maxWait}) {
  if (document.activeElement === element) return;
  const deferred = pDefer();
  element.addListener("onfocus", () => {
     assert document.activeElement === element;
     deferred.resolve();
  }, {once: true});
  element.focus();
  return deferred.promise;
}

@fregante
Copy link
Owner Author

It's kind of unfortunate because the module now is synchronous, but with that I'd have to make every call async. But it looks about right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants