Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BL-12820 fix double click selecting books in collections tab #6176

Draft
wants to merge 1 commit into
base: Version5.6
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/BloomBrowserUI/collectionsTab/BookButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,18 +326,24 @@ export const BookButton: React.FunctionComponent<{
};

const handleClick = (event: React.MouseEvent<HTMLElement>) => {
if (props.book.id !== props.manager.getSelectedBookInfo()?.id) {
// Not only is it useless to select the book that is already selected,
// it might have side effects. This might have been a contributing factor
// to the rename box getting blurred when clicked in.
setSelectedBookIdWithApi(props.book.id);
}
if (event.detail === 1) {
setTimeout(() => {
if (props.book.id !== props.manager.getSelectedBookInfo()?.id) {
// Not only is it useless to select the book that is already selected,
// it might have side effects. This might have been a contributing factor
// to the rename box getting blurred when clicked in.
setSelectedBookIdWithApi(props.book.id);
}

// There's a default right-click menu implemented by C# code which we don't want here.
// Also BooksOfCollection implements a different context menu when a click isn't
// intercepted here, and we don't want to get it as well.
event.preventDefault();
event.stopPropagation();
// There's a default right-click menu implemented by C# code which we don't want here.
// Also BooksOfCollection implements a different context menu when a click isn't
// intercepted here, and we don't want to get it as well.
event.preventDefault();
event.stopPropagation();
}, 200);
} else if (event.detail === 2) {
handleDoubleClick(event);
}
};

const handleDoubleClick = (event: React.MouseEvent<HTMLElement>) => {
Expand Down Expand Up @@ -448,7 +454,6 @@ export const BookButton: React.FunctionComponent<{
variant="outlined"
size="large"
title={props.book.folderPath}
onDoubleClick={handleDoubleClick}
onClick={e => handleClick(e)}
onContextMenu={e => handleContextClick(e)}
startIcon={
Expand Down