Skip to content

Conversation

eymar
Copy link
Member

@eymar eymar commented Aug 7, 2025

Fixes https://youtrack.jetbrains.com/issue/CMP-8725

This code returns a "read" function(), not the boolean :

js("window.navigator.clipboard && window.navigator.clipboard.read")

but in the kotlin usage the returned value was compared with "true". And the comparison was false. For example document.addEventListener == true // false.

Testing

This should be tested by QA

Release Notes

Fixes - Web

  • (prerelease fix) The context menu had only "Select All" item when targeting k/js

@eymar eymar requested a review from Schahen August 7, 2025 15:24

internal actual fun Clipboard.isWriteSupported(): Boolean =
js("window.navigator.clipboard && (window.navigator.clipboard.write || window.navigator.clipboard.writeText)")
js("Boolean(window.navigator.clipboard && (window.navigator.clipboard.write || window.navigator.clipboard.writeText))")
Copy link

Choose a reason for hiding this comment

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

this is js target - why we need this js wrapper and not acessing this entities directly? They are not declared in the stdlib?

Copy link
Member Author

@eymar eymar Aug 7, 2025

Choose a reason for hiding this comment

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

they are not nullable in kotlin.

And checking if a function is present or not is not possible in kotlin code, unless casting to dynamic.

@eymar eymar merged commit f2f1850 into jb-main Aug 7, 2025
10 of 12 checks passed
@eymar eymar deleted the ok/fix_clipboard_items_in_ctx_menu branch August 7, 2025 15:47
eymar added a commit that referenced this pull request Aug 7, 2025
Fixes https://youtrack.jetbrains.com/issue/CMP-8725

This code returns a "read" function(), not the boolean :
```
js("window.navigator.clipboard && window.navigator.clipboard.read")
```

but in the kotlin usage the returned value was compared with "true". And
the comparison was false. For example `document.addEventListener ==
true` // false.

## Testing
This should be tested by QA

## Release Notes
###  Fixes - Web
- _(prerelease fix)_ The context menu had only "Select All" item when
targeting k/js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants