Skip to content

Build your personal knowledge base with Trilium Notes

fix(totp): render recovery-dot used-date via Bootstrap tooltip, unescaped

Elian Doranc0c5b28c1325
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index f3f9d40a2d..ab09030e6c 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1737,7 +1737,7 @@
"recovery_keys_label": "Recovery codes",
"recovery_keys_remaining": "{{remaining}} of {{total}} remaining. Can't be shown again, only replaced.",
"recovery_keys_dot_available": "Available",
- "recovery_keys_dot_used": "Used on {{date}}",
+ "recovery_keys_dot_used": "Used on {{- date}}",
"oauth_title": "OpenID Connect",
"oauth_status_configured": "Configured",
"oauth_status_not_configured": "Not configured",
diff --git a/apps/client/src/widgets/type_widgets/options/totp.tsx b/apps/client/src/widgets/type_widgets/options/totp.tsx
index 64c0a1dfb7..53a888bbc8 100644
--- a/apps/client/src/widgets/type_widgets/options/totp.tsx
+++ b/apps/client/src/widgets/type_widgets/options/totp.tsx
@@ -18,6 +18,7 @@ import FormCheckbox from "../../react/FormCheckbox";
import FormGroup from "../../react/FormGroup";
import FormText from "../../react/FormText";
import FormTextBox from "../../react/FormTextBox";
+import { useStaticTooltip } from "../../react/hooks";
import Modal from "../../react/Modal";
import { RawHtmlBlock } from "../../react/RawHtml";
import { OptionsRowWithButton } from "./components/OptionsRow";
@@ -503,11 +504,20 @@ function TotpRecoveryKeys({ status, onRegenerate, onRemoveTotp }: {
/**
* A row of dots, one per recovery code in order, showing at a glance which codes are still available
- * (filled) and which have been spent (hollow). Each dot carries a tooltip with its status.
+ * (filled) and which have been spent (hollow). Each dot carries a Bootstrap tooltip with its status,
+ * delegated from the container via a `selector` so a single tooltip instance covers every dot and
+ * reads each dot's own `title` on hover.
*/
function RecoveryCodeDots({ status }: { status: string[] }) {
+ const dotsRef = useRef<HTMLDivElement>(null);
+ useStaticTooltip(dotsRef, {
+ selector: ".recovery-code-dot",
+ animation: false,
+ title() { return this.getAttribute("title") ?? ""; }
+ });
+
return (
- <div className="recovery-code-dots">
+ <div className="recovery-code-dots" ref={dotsRef}>
{status.map((entry, index) => {
const unused = isUnusedRecoveryCode(entry);
return (