Skip to content

Commit

Permalink
Revert "fix to make scripture selection easier."
Browse files Browse the repository at this point in the history
This reverts commit b3c9bb4.
  • Loading branch information
PhotoNomad0 committed Dec 4, 2023
1 parent b3c9bb4 commit 322446d
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions src/components/verse-objects/AlignedWordsObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import { default as WordLexiconDetails } from 'tc-ui-toolkit/lib/WordLexiconDeta
import { SelectionsContext } from '../selections/Selections.context';
import { WordObject, OriginalWordObject } from '.';

const intervalBeforePopup = 500; // delay 1/2 sec. before showing popup

function AlignedWordsObject({
children,
verseKey,
Expand All @@ -21,26 +19,14 @@ function AlignedWordsObject({
translate,
}) {
const classes = useStyles();
const [popupPosition, setPopupPosition] = useState(null);
const [readyToShow, setReadyToShow] = useState(false);
const [anchorEl, setAnchorEl] = useState(null);

const handleOpen = (event) => {
setReadyToShow(false); // make sure cleared

if (!event.buttons) { // only show popup if buttons not depressed (i.e. not selection text)
setPopupPosition(event.currentTarget); // save the anchor element for positioning

delay(intervalBeforePopup).then(() => {
setReadyToShow(true);
});
} else { // if dragging make position for popup is cleared
setPopupPosition(null);
}
setAnchorEl(event.currentTarget);
};

const handleClose = () => {
setPopupPosition(null);
setReadyToShow(false);
setAnchorEl(null);
};

let selected;
Expand Down Expand Up @@ -100,8 +86,8 @@ function AlignedWordsObject({
}

if (!disableWordPopover) {
const openPopup = readyToShow && Boolean(popupPosition);
const id = openPopup ? 'popover' : undefined;
const open = Boolean(anchorEl);
const id = open ? 'popover' : undefined;
const _originalWords = originalWords.map((verseObject, index) => getOriginalWordObject(index, verseObject));

component = (
Expand All @@ -111,14 +97,14 @@ function AlignedWordsObject({
aria-haspopup="true"
onMouseEnter={handleOpen}
onMouseLeave={handleClose}
className={openPopup ? classes.open : classes.closed}
className={open ? classes.open : classes.closed}
>
{words}
</span>
<Popover
id={id}
open={openPopup}
anchorEl={popupPosition}
open={open}
anchorEl={anchorEl}
onClose={handleClose}
className={classes.popover}
classes={{ paper: classes.paper }}
Expand Down Expand Up @@ -165,10 +151,4 @@ function translate_(key) {
return key;
}

function delay(ms) {
return new Promise((resolve) =>
setTimeout(resolve, ms),
)
}

export default AlignedWordsObject;

0 comments on commit 322446d

Please sign in to comment.