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

Update Clipboard.set to restore clobbered global state #524

Merged
merged 2 commits into from
Dec 6, 2021

Conversation

ryanprior
Copy link
Contributor

The Clipboard.set method clobbers the global state, removing focus from the current active element and removing all content selections. This PR updates the method to remember the initial active element and selection(s), restoring them after the clipboard operation is complete.

It also updates Clipboard.set to return its argument for convenient chaining and removes ; which was put at the end of some lines but not others, and isn't necessary.

The `Clipboard.set` method clobbers the global state, removing focus from the
current active element and removing all content selections. This commit
remembers the initial active element and selection(s), restoring them after the
clipboard operation is complete.

It also updates `Clipboard.set` to return its argument for convenient chaining.
textarea.remove()
})()
`
fun set (value : String) : String {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep it as a Promise(Never, String) mainly because at some point it will support the async clipboard api.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you like me to go ahead and rewrite to to use that API?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you feel like it, that would be great :) In another PR and using this as a fallback (if ('clipboard' in navigator) ...).

core/source/Clipboard.mint Outdated Show resolved Hide resolved
@gdotdesign gdotdesign merged commit 26568b9 into mint-lang:master Dec 6, 2021
@Sija Sija added bug Something isn't working stdlib Standard library related labels Dec 6, 2021
@Sija Sija added this to the 0.15.0 milestone Dec 6, 2021
@ryanprior ryanprior deleted the hygenic-clipboard-set branch December 6, 2021 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stdlib Standard library related
Development

Successfully merging this pull request may close these issues.

3 participants