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

copy button - initialized clipboardJS for support in modal window #8992

Merged
merged 4 commits into from
Mar 6, 2024

Conversation

cderv
Copy link
Collaborator

@cderv cderv commented Mar 6, 2024

closes #8990

clipboardJS that powers the copy button needs to be aware of the container in focus for it to work. (https://github.com/zenorocha/clipboard.js#advanced-options & zenorocha/clipboard.js#368)

Currently, I don't think there is a way to initiallize when clipboardJS instance for handling both button in main body and those in modal windows. I did a few tries, but probably this is still a missing feature (zenorocha/clipboard.js#860)

So my understanding is that we need to initialize clipboardJS differently for code block inside modal window.

This PR makes the source code inside the Modal we create for source embedding works.

If we add new modals, we'll need probably to adapt as I did something quite scoped for the container right now. It could be probably made more global but the value takes only one element right now, so we need to select only one modals.

I tested this locally - as this is in browser, this is hard to test differently.

Regarding feature matrix, I am still unsure how to add this but it improve for sure the quality of the copy-button feature among code tools one

clipboardJS that powers the copy button needs to be aware of the container in focus for it to work. Currently, there is no way to initiallize when clipboardJS instance for handling both button in main body and those in modal windows.

So we need to initialize clipboardJS differently for the modal window.
@cderv cderv merged commit 9634601 into main Mar 6, 2024
47 checks passed
@cderv cderv deleted the html/clipboard-in-modal branch March 6, 2024 14:44
@cscheid
Copy link
Collaborator

cscheid commented Mar 6, 2024

I tested this locally - as this is in browser, this is hard to test differently.

FWIW we have playwright tests exactly for this kind of thing. No need to do that now, but it's probably worth it for us to start considering in the future.

@cderv
Copy link
Collaborator Author

cderv commented Mar 6, 2024

Oh thanks. I need to get more familiar with them. Thanks for the reminder.

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.

Faulty copy button from </> Code
2 participants