Skip to content

Commit

Permalink
fix(file-explorer): sort alpha & overflow scroll (#754)
Browse files Browse the repository at this point in the history
  • Loading branch information
danilowoz authored Feb 22, 2023
1 parent bee225f commit 254df65
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions sandpack-react/src/components/FileExplorer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { SandpackBundlerFiles } from "@codesandbox/sandpack-client";
import * as React from "react";

import { useSandpack } from "../../hooks/useSandpack";
Expand Down Expand Up @@ -61,24 +62,32 @@ export const SandpackFileExplorer = ({
[status]
);

const orderedFiles = Object.keys(files)
.sort()
.reduce<SandpackBundlerFiles>((obj, key) => {
obj[key] = files[key];
return obj;
}, {});

return (
<div
className={classNames(
stackClassName,
fileExplorerClassName,
`${THEME_PREFIX}-file-explorer`,
className
)}
{...props}
>
<ModuleList
activeFile={activeFile}
autoHiddenFiles={autoHiddenFiles}
files={files}
prefixedPath="/"
selectFile={openFile}
visibleFiles={visibleFilesFromProps}
/>
<div className={classNames(fileExplorerClassName)}>
<ModuleList
activeFile={activeFile}
autoHiddenFiles={autoHiddenFiles}
files={orderedFiles}
prefixedPath="/"
selectFile={openFile}
visibleFiles={visibleFilesFromProps}
/>
</div>
</div>
);
};

1 comment on commit 254df65

@vercel
Copy link

@vercel vercel bot commented on 254df65 Feb 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

sandpack-docs – ./website/docs

sandpack-docs-git-main-codesandbox1.vercel.app
sandpack.vercel.app
sandpack-docs-codesandbox1.vercel.app

Please sign in to comment.