Skip to content

Commit

Permalink
Merge pull request #13 from ozovalihasan/fix-middle-click
Browse files Browse the repository at this point in the history
Fix the middle button used to select the table name
  • Loading branch information
ozovalihasan authored Apr 17, 2023
2 parents daf3a38 + f12fa1c commit 2fe6632
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion documents/how-to-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ An entity can be added by dragging and dropping a table.

## How to change the related table of an entity?

When the table name of an entity is clicked by the middle mouse button, a dropdown list will be opened. The related table can be changed by selecting any of the table names.
When the table name of an entity is clicked by the right mouse button, a dropdown list will be opened. The related table can be changed by selecting any of the table names.

![change table name of entity EAD](./images/change-table-name-of-entity-ead.gif)

Expand Down
Binary file modified documents/images/change-table-name-of-entity-ead.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 7 additions & 7 deletions src/components/TableName/TableName.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export const TableName =memo( ({ nodeId, tableId }: {nodeId: string, tableId: st
const options = Object.entries(tables).map(([id, table]) => {return {id: id, name: table.name}});

const handleMouseUp = (event: React.MouseEvent<HTMLDivElement> ) => {
if (event.button === 1){
handleMouseUpForSelect(selectEl)
selectEl.current!.focus()
}
event.preventDefault()

handleMouseUpForSelect(selectEl);
selectEl.current!.focus();
}

const handleMouseLeave = () => {
Expand All @@ -35,11 +35,11 @@ export const TableName =memo( ({ nodeId, tableId }: {nodeId: string, tableId: st

return (
<div
className='text-xs flex relative'
className='text-xs flex relative nopan'
onMouseLeave={handleMouseLeave}
title="Middle button click to change the table"
title="Right button click to change the table"
>
<div onMouseUp={event => handleMouseUp(event)} className="font-bold custom-select-button p-1 rounded-md">
<div onContextMenu={event => handleMouseUp(event)} className="font-bold custom-select-button p-1 rounded-md">
{tableName}
</div>
<select
Expand Down
2 changes: 1 addition & 1 deletion src/components/TableName/test/TableName.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('<TableName />', () => {
render(renderReadyComponent);

const buttonEl = screen.getAllByText(/Mock Name/i)[0]
fireEvent.mouseUp(buttonEl, {button: 1})
fireEvent.contextMenu(buttonEl)

});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Object {
"baseElement": <body>
<div>
<div
class="text-xs flex relative"
title="Middle button click to change the table"
class="text-xs flex relative nopan"
title="Right button click to change the table"
>
<div
class="font-bold custom-select-button p-1 rounded-md"
Expand Down Expand Up @@ -36,8 +36,8 @@ Object {
</body>,
"container": <div>
<div
class="text-xs flex relative"
title="Middle button click to change the table"
class="text-xs flex relative nopan"
title="Right button click to change the table"
>
<div
class="font-bold custom-select-button p-1 rounded-md"
Expand Down

0 comments on commit 2fe6632

Please sign in to comment.