egui icon indicating copy to clipboard operation
egui copied to clipboard

unstable clipboard logic on web is incompatible with web_sys 0.3.70

Open simon-wh opened this issue 1 year ago • 2 comments

I'm trying to use web_sys_unstable_apis in my project, but it started failing due to an error coming from some special clipboard logic in eframe.

The error:

   --> /Users/syte-laptop/.cargo/registry/src/index.crates.io-6f17d22bba15001f/eframe-0.28.1/src/web/mod.rs:187:16
    |
187 |         if let Some(clipboard) = window.navigator().clipboard() {
    |                ^^^^^^^^^^^^^^^   ------------------------------ this expression has type `Clipboard`
    |                |
    |                expected `Clipboard`, found `Option<_>`
    |
    = note: expected struct `Clipboard`
                 found enum `Option<_>`

The source: https://github.com/emilk/egui/blob/master/crates/eframe/src/web/mod.rs#L171-L192

In v0.3.69 and before of web_sys, the return of .clipboard() is Option<Clipboard>. In v0.3.70, it is now just Clipboard

Thankfully, I'm able to just pin my web_sys dependency to =0.3.69 and I'm able to compile again

simon-wh avatar Aug 14 '24 14:08 simon-wh

@simon-wh Could you test if the branch from PR #4954 works for you?

bircni avatar Aug 14 '24 18:08 bircni

@simon-wh Could you test if the branch from PR #4954 works for you?

Looks to be working 👍

Compiling that is, I'm not using this clipboard behaviour so I cannot validate the updated logic

simon-wh avatar Aug 14 '24 18:08 simon-wh

I also met this problem. When will the #4954 be merged? 😄

bioinformatist avatar Aug 25 '24 12:08 bioinformatist

@bioinformatist please have a look at #4980

bircni avatar Aug 25 '24 13:08 bircni