Skip to content

Commit

Permalink
Merge pull request #27 from gautamkrishnar/feat/double-click
Browse files Browse the repository at this point in the history
Added double click to open the table editor
  • Loading branch information
1ilit authored Apr 11, 2024
2 parents 1f78ba8 + 7023b2e commit cd90fae
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions src/components/EditorCanvas/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ export default function Table(props) {

const height =
tableData.fields.length * tableFieldHeight + tableHeaderHeight + 7;
const openEditor = () => {
if (!layout.sidebar) {
setSelectedElement((prev) => ({
...prev,
element: ObjectType.TABLE,
id: tableData.id,
open: true,
}));
} else {
setSelectedElement((prev) => ({
...prev,
currentTab: Tab.TABLES,
element: ObjectType.TABLE,
id: tableData.id,
open: true,
}));
if (selectedElement.currentTab !== Tab.TABLES) return;
document
.getElementById(`scroll_table_${tableData.id}`)
.scrollIntoView({ behavior: "smooth" });
}
}

return (
<>
Expand All @@ -45,6 +67,7 @@ export default function Table(props) {
onMouseDown={onMouseDown}
>
<div
onDoubleClick={openEditor}
className={`border-2 hover:border-dashed hover:border-blue-500
select-none rounded-lg w-full ${
settings.mode === "light"
Expand Down Expand Up @@ -80,28 +103,7 @@ export default function Table(props) {
opacity: "0.7",
marginRight: "6px",
}}
onClick={() => {
if (!layout.sidebar) {
setSelectedElement((prev) => ({
...prev,
element: ObjectType.TABLE,
id: tableData.id,
open: true,
}));
} else {
setSelectedElement((prev) => ({
...prev,
currentTab: Tab.TABLES,
element: ObjectType.TABLE,
id: tableData.id,
open: true,
}));
if (selectedElement.currentTab !== Tab.TABLES) return;
document
.getElementById(`scroll_table_${tableData.id}`)
.scrollIntoView({ behavior: "smooth" });
}
}}
onClick={openEditor}
/>
<Popover
content={
Expand Down

0 comments on commit cd90fae

Please sign in to comment.