@@ -102,18 +102,25 @@ const clearSelection = () => {
102
102
}
103
103
}
104
104
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
+
106
111
const temporarilyChangeTooltip = (el, oldText, newText) => {
107
112
el.setAttribute('data-tooltip', newText)
108
113
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)
111
118
}
112
119
113
120
// Changes the copy button icon for two seconds, then changes it back
114
121
const temporarilyChangeIcon = (el) => {
115
122
el.innerHTML = iconCheck;
116
- setTimeout(() => {el.innerHTML = iconCopy}, 2000 )
123
+ setTimeout(() => {el.innerHTML = iconCopy}, timeoutIcon )
117
124
}
118
125
119
126
const addCopyButtonToCodeCells = () => {
0 commit comments