JedWatson / JedWatson/react-select

Does not work with astro3 ViewTransitions

Open
#5,781 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue/bug-unconfirmed
Dominant language
TypeScript
Stars
28k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

In astro3 with ViewTransitions enabled, and the React integrations, this components css is lost every time a viewTransition fires. So whenever you navigate.

https://docs.astro.build/en/guides/view-transitions/

https://docs.astro.build/en/guides/integrations-guide/react/

https://github.com/JedWatson/react-select/assets/73557008/c9b138b2-48ca-4246-bd97-d7c09f75f055

import { useState } from "react";
import { themeColors } from "../../../theme/themeColors";
import Select, { type StylesConfig } from "react-select";

interface DawOption {
  readonly value: string;
  readonly label: string;
  readonly isDisabled?: boolean;
}
export const DawDropDown = () => {
  const colorStyles: StylesConfig<DawOption> = {
    control: (styles) => ({
      ...styles,
      backgroundColor: "white",
      minWidth: "140px",
    }),
    option: (styles, { isDisabled, isFocused, isSelected }) => {
      const bgColor = isSelected
        ? themeColors.accentHilite
        : isFocused
        ? themeColors.darkenedText // on hover
        : undefined;
      if (isDisabled)
        return {
          ...styles,
          backgroundColor: "white",
          color: themeColors.darkenedText,
          cursor: "not-allowed",
        };

      return {
        ...styles,
        backgroundColor: bgColor,
        color: isSelected ? themeColors.text : themeColors.mainBackground,
        cursor: "default",

        ":active": {
          ...styles[":active"],
          backgroundColor: isSelected
            ? themeColors.mainBackground
            : themeColors.text,
        },
      };
    },
    input: (styles) => ({ ...styles }),
    placeholder: (styles) => ({ ...styles }),
    singleValue: (styles, { data }) => ({ ...styles }),
  };

  const [selectedOption, setSelectedOption] = useState<any>(null);
  if (selectedOption) console.log(selectedOption);
  const dawOptions: readonly DawOption[] = [
    {
      value: "Select DAW",
      label: "Select DAW",
      isDisabled: true,
    },
    {
      value: "ProTools",
      label: "ProTools",
    },
    {
      value: "Ableton",
      label: "Ableton",
    },
    {
      value: "Reaper",
      label: "Reaper",
    },
    {
      value: "Logic",
      label: "Logic",
    },
    {
      value: "Cubase",
      label: "Cubase",
    },
    {
      value: "FL Studio",
      label: "FL Studio",
    },
  ];
  return (
    <Select
      defaultValue={dawOptions[0]}
      options={dawOptions}
      onChange={setSelectedOption}
      styles={colorStyles}
    />
  );
};

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with Astro 3, ViewTransitions, and the React integration using the linked Astro guides and example component. Inspect how react-select styles are handled across navigation; done means the component CSS remains present after each view transition.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.