Browse Source

chore: Fix some code quality issues

Trying to get Sonar to stop making bad red cross
Michael Bromley 7 months ago
parent
commit
65c25ff01e

+ 10 - 8
packages/dashboard/src/lib/components/data-input/richt-text-input.tsx

@@ -43,15 +43,17 @@ export function RichTextInput({ value, onChange }: RichTextInputProps) {
         },
     });
 
-    if (!editor) return null;
-
     useLayoutEffect(() => {
-        const { from, to } = editor.state.selection;
-    
-        editor.commands.setContent(value, false);
-    
-        editor.commands.setTextSelection({ from, to });
-      }, [value]);
+        if (editor) {
+            const { from, to } = editor.state.selection;
+            editor.commands.setContent(value, false);
+            editor.commands.setTextSelection({ from, to });
+        }
+    }, [value, editor]);
+
+    if (!editor) {
+        return null;
+    }
 
     return (
         <>

+ 4 - 4
packages/dashboard/src/lib/components/data-table/human-readable-operator.tsx

@@ -31,7 +31,7 @@ export function HumanReadableOperator({
         case 'between':
             return mode === 'short' ? <Trans>between</Trans> : <Trans>is between</Trans>;
         case 'isNull':
-            return mode === 'short' ? <Trans>is null</Trans> : <Trans>is null</Trans>;
+            return <Trans>is null</Trans>;
         case 'in':
             return mode === 'short' ? <Trans>in</Trans> : <Trans>is in</Trans>;
         case 'notIn':
@@ -53,11 +53,11 @@ export function HumanReadableOperator({
                 <Trans>is less than or equal to</Trans>
             );
         case 'contains':
-            return mode === 'short' ? <Trans>contains</Trans> : <Trans>contains</Trans>;
+            return <Trans>contains</Trans>;
         case 'notContains':
-            return mode === 'short' ? <Trans>does not contain</Trans> : <Trans>does not contain</Trans>;
+            return <Trans>does not contain</Trans>;
         case 'regex':
-            return mode === 'short' ? <Trans>matches regex</Trans> : <Trans>matches regex</Trans>;
+            return <Trans>matches regex</Trans>;
         default:
             operator satisfies never;
             return <Trans>{operator}</Trans>;

+ 2 - 0
packages/dashboard/src/lib/components/shared/entity-assets.tsx

@@ -76,6 +76,8 @@ function FeaturedAsset({
             ) : (
                 <div
                     className="flex flex-col items-center justify-center text-muted-foreground cursor-pointer"
+                    onKeyDown={e => e.key === 'Enter' && onSelectAssets()}
+                    tabIndex={0}
                     onClick={onSelectAssets}
                 >
                     <ImageIcon className={compact ? 'h-10 w-10' : 'h-16 w-16'} />