Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## Unreleased

- Opted out of translation for high-churn UI regions (search suggestions and moderation counters) using the `NoTranslate` wrapper to avoid Google Translate DOM churn.
14 changes: 14 additions & 0 deletions src/components/NoTranslate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"use client";
import React from "react";
export function NoTranslate(props: React.HTMLAttributes<HTMLDivElement>) {
const { className, children, ...rest } = props;
return (
<div
translate="no"
className={["notranslate", className].filter(Boolean).join(" ")}
{...rest}
>
{children}
</div>
);
}
11 changes: 8 additions & 3 deletions src/components/feedback/review-list-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { toast } from "sonner";
import Spinner from "@/components/spinner";
import ReportComment from "@/components/feedback/report-comment";
import { clsx } from "clsx";
import { NoTranslate } from "@/components/NoTranslate";

export default function ReviewListItem({
comment,
Expand Down Expand Up @@ -168,10 +169,10 @@ export default function ReviewListItem({
</div>
</div>
{comment.report_count > 0 && (isAdmin || isStuffUser) && (
<span className="text-xs ml-3 self-start gap-1 border border-red-500 bg-red-500/10 text-red-500 px-2 py-0.5 rounded-full inline-flex items-center">
<NoTranslate className="text-xs ml-3 self-start gap-1 border border-red-500 bg-red-500/10 text-red-500 px-2 py-0.5 rounded-full inline-flex items-center">
<ExclamationTriangleIcon className="w-4 h-4" />
<span>{comment.report_count}</span>
</span>
</NoTranslate>
)}
</div>
<DropdownMenu>
Expand Down Expand Up @@ -292,7 +293,11 @@ export default function ReviewListItem({
>
<HandThumbUpIcon />
<span>Helpful</span>
{comment.likes_count > 0 && <span>({comment.likes_count})</span>}
{comment.likes_count > 0 && (
<NoTranslate className="inline-flex">
<span>({comment.likes_count})</span>
</NoTranslate>
)}
</Button>

{isStuffUser === null ? (
Expand Down
7 changes: 4 additions & 3 deletions src/components/search-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { XMarkIcon } from "@heroicons/react/24/outline";
import { SearchContext, SearchContextType } from "./search-context";
import { PreviousParams } from "./get-previous-params";
import { usePreviousParamsOnClient } from "./use-previous-params-client";
import { NoTranslate } from "./NoTranslate";

function SearchPanel({
currentSearch,
Expand Down Expand Up @@ -74,9 +75,9 @@ function SearchPanel({
/>
<div className="flex-1 text-dark">
<span>Search for</span>{" "}
<span id="search_for" translate="no">
{currentSearch}
</span>
<NoTranslate id="search_for" className="inline">
<span>{currentSearch}</span>
</NoTranslate>
</div>
<span className="text-dark">
<svg
Expand Down