Skip to content

Commit

Permalink
fix cell name in dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
mscolnick committed Jun 4, 2024
1 parent 89d6ea8 commit 971ea33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 11 additions & 3 deletions frontend/src/components/editor/actions/useCellActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
getEditorViewMode,
toggleMarkdown,
} from "@/core/codemirror/format";
import { hasOnlyOneCellAtom, useCellActions } from "@/core/cells/cells";
import {
hasOnlyOneCellAtom,
useCellActions,
useCellIds,
} from "@/core/cells/cells";
import {
ImageIcon,
Code2Icon,
Expand Down Expand Up @@ -77,10 +81,14 @@ export function useCellActionButtons({ cell }: Props) {
const setAiCompletionCell = useSetAtom(aiCompletionCellAtom);
const aiEnabled = useAtomValue(aiEnabledAtom);
const autoInstantiate = useAtomValue(autoInstantiateAtom);
const cellIds = useCellIds();

if (!cell) {
return [];
}

const { cellId, config, getEditorView, name, hasOutput, status } = cell;
const cellIdx = cellIds.indexOf(cellId);
const editorView = getEditorView();

const toggleDisabled = async () => {
Expand Down Expand Up @@ -125,7 +133,7 @@ export function useCellActionButtons({ cell }: Props) {
<div className="flex items-center justify-between">
<Label htmlFor="cell-name">Cell name</Label>
<NameCellInput
placeholder={`cell_${cellId}`}
placeholder={`cell_${cellIdx}`}
value={name}
onKeyDown={(e) => {
if (e.key === "Enter") {
Expand All @@ -144,7 +152,7 @@ export function useCellActionButtons({ cell }: Props) {
},
rightElement: (
<NameCellInput
placeholder={`cell_${cellId}`}
placeholder={`cell_${cellIdx}`}
value={name}
onChange={(newName) => updateCellName({ cellId, name: newName })}
/>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/editor/links/cell-link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export function scrollAndHighlightCell(
cell.classList.add("error-outline");
setTimeout(() => {
cell.classList.remove("error-outline");
}, 1500);
}, 2000);
}
if (variant === "focus") {
cell.classList.add("focus-outline");
setTimeout(() => {
cell.classList.remove("focus-outline");
}, 1500);
}, 2000);
}

return true;
Expand Down

0 comments on commit 971ea33

Please sign in to comment.