From cd7560dded08510a45473b8718172ce080583a9c Mon Sep 17 00:00:00 2001 From: ashmod Date: Wed, 1 Apr 2026 19:44:38 +0200 Subject: [PATCH] add copy btn ui feedback --- gcp/website/frontend3/src/index.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcp/website/frontend3/src/index.js b/gcp/website/frontend3/src/index.js index e0f6ada973b..10f607f2c95 100644 --- a/gcp/website/frontend3/src/index.js +++ b/gcp/website/frontend3/src/index.js @@ -9,6 +9,16 @@ import { MdFilledTextField } from '@material/web/textfield/filled-text-field.js' import { LitElement, html } from 'lit'; import { ExpandableSearch, SearchSuggestionsManager } from './search.js'; +const COPY_ICON_RESET_MS = 1500; + +document.addEventListener('clipboard-copy', ({target}) => { + const icon = target.querySelector('md-icon'); + if (!icon) return; + clearTimeout(target._copyResetTimer); + icon.textContent = 'check'; + target._copyResetTimer = setTimeout(() => { icon.textContent = 'content_copy'; }, COPY_ICON_RESET_MS); +}); + // Submits a form in a way such that Turbo can intercept the event. // Triggering submit on the form directly would still give a correct resulting // page, but we want to let Turbo speed up renders as intended.