Repository navigation
perf(desktop): stop hidden right-pane and background work on every git change #9149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
96bf6e0
8c4c99c
f5d990d
1e33963
9569405
9bf4452
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import { Trans, useLingui } from "@lingui/react/macro"; | ||
| import { ScrollArea } from "@superset/ui/scroll-area"; | ||
| import { Check } from "lucide-react"; | ||
| import { useMemo, useState } from "react"; | ||
| import type { Branch } from "../../../../types"; | ||
|
|
||
| interface BranchListProps { | ||
| branches: Branch[]; | ||
| currentValue: string; | ||
| onPick: (branchName: string) => void; | ||
| } | ||
|
|
||
| export function BranchList({ | ||
| branches, | ||
| currentValue, | ||
| onPick, | ||
| }: BranchListProps) { | ||
| const { t } = useLingui(); | ||
| const [search, setSearch] = useState(""); | ||
|
|
||
| const filtered = useMemo(() => { | ||
| if (!search) return branches; | ||
| const lower = search.toLowerCase(); | ||
| return branches.filter((b) => b.name.toLowerCase().includes(lower)); | ||
| }, [branches, search]); | ||
|
|
||
| return ( | ||
| <> | ||
| <div className="border-b px-3 py-2"> | ||
| <input | ||
| placeholder={t({ | ||
| message: "Search branches...", | ||
| })} | ||
| value={search} | ||
| onChange={(e) => setSearch(e.target.value)} | ||
| className="w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground" | ||
| /> | ||
| </div> | ||
| <ScrollArea className="flex-1 overflow-y-auto"> | ||
| <div className="p-1"> | ||
| {filtered.map((branch) => ( | ||
| <button | ||
| key={branch.name} | ||
| type="button" | ||
| className="flex w-full items-center justify-between rounded-sm px-2 py-1.5 text-sm hover:bg-accent" | ||
| onClick={() => onPick(branch.name)} | ||
| > | ||
| <span className="truncate">{branch.name}</span> | ||
| {branch.name === currentValue && ( | ||
| <Check className="size-3.5 shrink-0" /> | ||
| )} | ||
| </button> | ||
| ))} | ||
| {filtered.length === 0 && ( | ||
| <div className="px-2 py-3 text-center text-sm text-muted-foreground"> | ||
| <Trans>No branches found</Trans> | ||
| </div> | ||
| )} | ||
| </div> | ||
| </ScrollArea> | ||
| </> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { BranchList } from "./BranchList"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ import { | |
| memo, | ||
| useDeferredValue, | ||
| } from "react"; | ||
| import { TabVisibilityContext } from "../../../../hooks/useIsTabVisible"; | ||
| import { Tab } from "../Tab"; | ||
| import { TabVisibilityScope } from "./components/TabVisibilityScope"; | ||
|
|
||
| // Unlike display:none, this keeps the hidden tab's layout, so its resize | ||
| // observers see no 0-size and its scroll offsets survive. | ||
|
|
@@ -30,9 +30,9 @@ function KeptTabView<TData>({ isVisible, ...tabProps }: KeptTabProps<TData>) { | |
| inert={!isVisible} | ||
| aria-hidden={isVisible ? undefined : true} | ||
| > | ||
| <TabVisibilityContext.Provider value={isPaneVisible}> | ||
| <TabVisibilityScope visible={isPaneVisible}> | ||
| <MemoTab {...tabProps} /> | ||
| </TabVisibilityContext.Provider> | ||
| </TabVisibilityScope> | ||
|
Comment on lines
+33
to
+35
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { renderToStaticMarkup } from "react-dom/server"; | ||
| import { | ||
| TabVisibilityContext, | ||
| useIsTabVisible, | ||
| } from "../../../../../../hooks/useIsTabVisible"; | ||
| import { TabVisibilityScope } from "./TabVisibilityScope"; | ||
|
|
||
| function Probe() { | ||
| return <i>{String(useIsTabVisible())}</i>; | ||
| } | ||
|
|
||
| function seenBy(parentVisible: boolean, tabVisible: boolean) { | ||
| return renderToStaticMarkup( | ||
| <TabVisibilityContext.Provider value={parentVisible}> | ||
| <TabVisibilityScope visible={tabVisible}> | ||
| <Probe /> | ||
| </TabVisibilityScope> | ||
| </TabVisibilityContext.Provider>, | ||
| ); | ||
| } | ||
|
|
||
| describe("TabVisibilityScope", () => { | ||
| test("an active tab is hidden while its parent is hidden", () => { | ||
| expect(seenBy(false, true)).toBe("<i>false</i>"); | ||
| expect(seenBy(true, true)).toBe("<i>true</i>"); | ||
| }); | ||
|
|
||
| test("an inactive tab stays hidden when its parent is shown", () => { | ||
| expect(seenBy(true, false)).toBe("<i>false</i>"); | ||
| expect(seenBy(false, false)).toBe("<i>false</i>"); | ||
| }); | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import type { ReactNode } from "react"; | ||
| import { | ||
| TabVisibilityContext, | ||
| useIsTabVisible, | ||
| } from "../../../../../../hooks/useIsTabVisible"; | ||
|
|
||
| interface TabVisibilityScopeProps { | ||
| visible: boolean; | ||
| children: ReactNode; | ||
| } | ||
|
|
||
| export function TabVisibilityScope({ | ||
| visible, | ||
| children, | ||
| }: TabVisibilityScopeProps) { | ||
| const isParentVisible = useIsTabVisible(); | ||
| return ( | ||
| <TabVisibilityContext.Provider value={visible && isParentVisible}> | ||
| {children} | ||
| </TabVisibilityContext.Provider> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { TabVisibilityScope } from "./TabVisibilityScope"; |
Uh oh!
There was an error while loading. Please reload this page.