fix event triggered when hold mouse click and release at sidebar

This commit is contained in:
game5413 2023-10-14 18:10:49 +07:00
parent 6b668aaebe
commit a0be0e10ac
2 changed files with 50 additions and 50 deletions

View File

@ -88,8 +88,6 @@ const CollectionItem = ({ item, collection, searchText }) => {
}); });
const handleClick = (event) => { const handleClick = (event) => {
switch (event.button) {
case 0: // left click
if (isItemARequest(item)) { if (isItemARequest(item)) {
dispatch(hideHomePage()); dispatch(hideHomePage());
if (itemIsOpenedInTabs(item, tabs)) { if (itemIsOpenedInTabs(item, tabs)) {
@ -115,8 +113,9 @@ const CollectionItem = ({ item, collection, searchText }) => {
collectionUid: collection.uid collectionUid: collection.uid
}) })
); );
return; };
case 2: // right click
const handleRightClick = (event) => {
const _menuDropdown = dropdownTippyRef.current; const _menuDropdown = dropdownTippyRef.current;
if (_menuDropdown) { if (_menuDropdown) {
let menuDropdownBehavior = 'show'; let menuDropdownBehavior = 'show';
@ -125,8 +124,6 @@ const CollectionItem = ({ item, collection, searchText }) => {
} }
_menuDropdown[menuDropdownBehavior](); _menuDropdown[menuDropdownBehavior]();
} }
return;
}
}; };
const handleDoubleClick = (event) => { const handleDoubleClick = (event) => {
@ -203,7 +200,8 @@ const CollectionItem = ({ item, collection, searchText }) => {
? indents.map((i) => { ? indents.map((i) => {
return ( return (
<div <div
onMouseUp={handleClick} onClick={handleClick}
onContextMenu={handleRightClick}
onDoubleClick={handleDoubleClick} onDoubleClick={handleDoubleClick}
className="indent-block" className="indent-block"
key={i} key={i}
@ -219,7 +217,8 @@ const CollectionItem = ({ item, collection, searchText }) => {
}) })
: null} : null}
<div <div
onMouseUp={handleClick} onClick={handleClick}
onContextMenu={handleRightClick}
onDoubleClick={handleDoubleClick} onDoubleClick={handleDoubleClick}
className="flex flex-grow items-center h-full overflow-hidden" className="flex flex-grow items-center h-full overflow-hidden"
style={{ style={{

View File

@ -66,12 +66,11 @@ const Collection = ({ collection, searchText }) => {
}); });
const handleClick = (event) => { const handleClick = (event) => {
const _menuDropdown = menuDropdownTippyRef.current;
switch (event.button) {
case 0: // left click
dispatch(collectionClicked(collection.uid)); dispatch(collectionClicked(collection.uid));
return; };
case 2: // right click
const handleRightClick = (event) => {
const _menuDropdown = menuDropdownTippyRef.current;
if (_menuDropdown) { if (_menuDropdown) {
let menuDropdownBehavior = 'show'; let menuDropdownBehavior = 'show';
if (_menuDropdown.state.isShown) { if (_menuDropdown.state.isShown) {
@ -79,8 +78,6 @@ const Collection = ({ collection, searchText }) => {
} }
_menuDropdown[menuDropdownBehavior](); _menuDropdown[menuDropdownBehavior]();
} }
return;
}
}; };
const handleExportClick = () => { const handleExportClick = () => {
@ -138,7 +135,11 @@ const Collection = ({ collection, searchText }) => {
<CollectionProperties collection={collection} onClose={() => setCollectionPropertiesModal(false)} /> <CollectionProperties collection={collection} onClose={() => setCollectionPropertiesModal(false)} />
)} )}
<div className="flex py-1 collection-name items-center" ref={drop}> <div className="flex py-1 collection-name items-center" ref={drop}>
<div className="flex flex-grow items-center overflow-hidden" onMouseUp={handleClick}> <div
className="flex flex-grow items-center overflow-hidden"
onClick={handleClick}
onContextMenu={handleRightClick}
>
<IconChevronRight <IconChevronRight
size={16} size={16}
strokeWidth={2} strokeWidth={2}