diff --git a/packages/desktop-client/src/components/common/InfoBubble.tsx b/packages/desktop-client/src/components/common/InfoBubble.tsx
index 1f1c4d203bb..ec682452347 100644
--- a/packages/desktop-client/src/components/common/InfoBubble.tsx
+++ b/packages/desktop-client/src/components/common/InfoBubble.tsx
@@ -1,8 +1,6 @@
import React, { useState } from 'react';
import { useLocation } from 'react-router-dom';
-import { getTextWidth } from 'loot-core/shared/text-width';
-
import { SvgInformationCircle } from '../../icons/v2';
import { theme } from '../../style';
@@ -11,14 +9,14 @@ import { View } from './View';
type InfoBubbleProps = {
label: string;
+ textWidth?: number;
};
-export function InfoBubble({ label }: InfoBubbleProps) {
+export function InfoBubble({ label, textWidth }: InfoBubbleProps) {
const location = useLocation();
const [visible, setVisible] = useState(location.hash === '#info');
- const bubbleWidth = getTextWidth(label, 500);
- console.log(bubbleWidth);
+ const width = textWidth || getStringWidth(label);
return visible ? (
@@ -43,7 +41,7 @@ export function InfoBubble({ label }: InfoBubbleProps) {
>
{label}
@@ -60,3 +58,11 @@ export function InfoBubble({ label }: InfoBubbleProps) {
);
}
+
+function getStringWidth(text: string): number {
+ const canvas = document.createElement('canvas');
+ const context = canvas.getContext('2d')!;
+ context.font = getComputedStyle(document.body).font;
+
+ return Math.ceil(context.measureText(text).width);
+}
diff --git a/packages/desktop-client/src/components/settings/Upcoming.tsx b/packages/desktop-client/src/components/settings/Upcoming.tsx
index c67f203bbb0..e556c2a7c0e 100644
--- a/packages/desktop-client/src/components/settings/Upcoming.tsx
+++ b/packages/desktop-client/src/components/settings/Upcoming.tsx
@@ -57,7 +57,7 @@ export function UpcomingLengthSettings() {
style={selectButtonStyle}
/>
-
+