ui icon indicating copy to clipboard operation
ui copied to clipboard

Select component broken when site is translated via Google translate page or browser translate

Open func0x opened this issue 2 years ago • 2 comments

If you use Select component example in here https://ui.shadcn.com/docs/components/select then translate page to different language in browser address bar, then select something, change selection, you have error "Application error: a client-side exception has occurred (see the browser console for more information)" froze whole site in console is "DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node"

func0x avatar Jul 06 '23 10:07 func0x

Hi @calciferlo. Using Google Translate adds an element to the page and NextJS complains because it doesn't know where the element came from. Adding translate="no" to the html tag should fix the issue.

dan5py avatar Jul 06 '23 12:07 dan5py

Is disabling the translation of the entire HTML the only way to avoid this issue? Sometimes users might indeed need the translation.

anson0370 avatar Jan 23 '24 18:01 anson0370

Did it work ?

DaniloAlvesantos avatar Apr 12 '24 16:04 DaniloAlvesantos

I use translate="no" and it's work. Close the issue.

func0x avatar Apr 18 '24 12:04 func0x

Wrapping the value in SelectItem with a <span> should be able to solve this problem.

Like below:

<Select>
  <SelectTrigger>
    <SelectValue/>
  </SelectTrigger>
  <SelectContent>
    {menuItems.map((item) => (
      <SelectItem key={item} value={item}>
        <span>{item}</span>
      </SelectItem>
    ))}
  </SelectContent>
</Select>

anson0370 avatar Apr 18 '24 12:04 anson0370