@@ -102,18 +102,25 @@ const clearSelection = () => {
102102 }
103103}
104104
105- // Changes tooltip text for two seconds, then changes it back
105+ // Changes tooltip text for a moment, then changes it back
106+ // We want the timeout of our `success` class to be a bit shorter than the
107+ // tooltip and icon change, so that we can hide the icon before changing back.
108+ var timeoutIcon = 2000;
109+ var timeoutSuccessClass = 1500;
110+
106111const temporarilyChangeTooltip = (el, oldText, newText) => {
107112 el.setAttribute('data-tooltip', newText)
108113 el.classList.add('success')
109- setTimeout(() => el.setAttribute('data-tooltip', oldText), 2000)
110- setTimeout(() => el.classList.remove('success'), 2000)
114+ // Remove success a little bit sooner than we change the tooltip
115+ // So that we can use CSS to hide the copybutton first
116+ setTimeout(() => el.classList.remove('success'), timeoutSuccessClass)
117+ setTimeout(() => el.setAttribute('data-tooltip', oldText), timeoutIcon)
111118}
112119
113120// Changes the copy button icon for two seconds, then changes it back
114121const temporarilyChangeIcon = (el) => {
115122 el.innerHTML = iconCheck;
116- setTimeout(() => {el.innerHTML = iconCopy}, 2000 )
123+ setTimeout(() => {el.innerHTML = iconCopy}, timeoutIcon )
117124}
118125
119126const addCopyButtonToCodeCells = () => {
0 commit comments