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

Behaviour of onselectionchange attribute on an element #1809

Closed
nbrr opened this issue Apr 3, 2021 · 2 comments
Closed

Behaviour of onselectionchange attribute on an element #1809

nbrr opened this issue Apr 3, 2021 · 2 comments
Labels
A-yew Area: The main yew crate bug S-waiting-on-author Status: awaiting action from the author of the issue/PR

Comments

@nbrr
Copy link

nbrr commented Apr 3, 2021

Problem

I mean to do something when text is selected. I built an example app for this issue, where when text is selected, the selection is displayed under the text.

Steps To Reproduce

I first attempted to use a callback on onselectionchange to trigger a new render, see example. This does not work. Note that using a onmousemove attribute, I get the expected high level behaviour when selecting with the mouse, see example.

Registering an event listener on the document works, see example.

Expected behavior
onselectionchange attribute to be enough to register a callback on the selectionchange event.

I note that selectionchange is a document event (mdn) while for example mousemove is an element event (mdn). If onselectionchange is not meant to be put on a div I would maybe expect that compilation fails?

Environment:

  • Yew version: 0.17.4
  • Rust version: 1.51.0
  • Build tool, if relevant: wasm-pack
  • OS: Windows 10
  • Browser and version, if relevant: Firefox 87
@nbrr nbrr added the bug label Apr 3, 2021
@mc1098
Copy link
Contributor

mc1098 commented Jul 10, 2021

Hi @nbrr,
I've been looking at this issue, btw thank you for the example repo made it easy to do :)
I'm not experiencing any problems or differences between the two version now. mdn does note in general that this is experimental so maybe this was a browser bug that has been fixed between your issue and now?
If you could confirm the same and close the issue if you agree and if I've missed something just let me know :)

@mc1098 mc1098 added A-yew Area: The main yew crate S-waiting-on-author Status: awaiting action from the author of the issue/PR labels Sep 20, 2021
@voidpumpkin
Copy link
Member

voidpumpkin commented Apr 3, 2023

If onselectionchange is not meant to be put on a div I would maybe expect that compilation fails?

No, we don't guarantee checks for all w3c specs. It would be too big of an overhead for an open source library.
Expected behavior for yew user is to check mdn or other documentation, like you did here.

I also have to note, yes i can still reproduce this on [email protected], but the event only will work when mounted on document element.
That is expected JavaScript behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-yew Area: The main yew crate bug S-waiting-on-author Status: awaiting action from the author of the issue/PR
Projects
None yet
Development

No branches or pull requests

3 participants