Skip to content

fix: fix double-click in read-only mode #179

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

Merged
merged 2 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<url>https://www.flowingcode.com/en/open-source/</url>

<properties>
<vaadin.version>14.8.20</vaadin.version>
<vaadin.version>14.11.13</vaadin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public enum Orientation {
private boolean explicitHeaderRow = true;

private String layoutId;

private static <T> ListDataProvider<T> emptyDataProvider() {
return DataProvider.ofCollection(new LinkedHashSet<>());
}
Expand Down Expand Up @@ -339,7 +339,7 @@ private String getLayoutId() {
return this.layoutId = "twincol-" + UUID.randomUUID();
});
}

private HorizontalLayout createHorizontalContainer(boolean reverse) {
buttonContainer = getVerticalButtonContainer();
HorizontalLayout hl;
Expand Down Expand Up @@ -928,12 +928,14 @@ public void setMoveItemsByDoubleClick(boolean value) {
side.moveItemsByDoubleClick =
side.grid.addItemDoubleClickListener(
ev -> {
Set<T> item = Collections.singleton(ev.getItem());
if (side == available) {
updateSelection(item, Collections.emptySet(), true);
}
if (side == selection) {
updateSelection(Collections.emptySet(), item, true);
if (!isReadOnly()) {
Set<T> item = Collections.singleton(ev.getItem());
if (side == available) {
updateSelection(item, Collections.emptySet(), true);
}
if (side == selection) {
updateSelection(Collections.emptySet(), item, true);
}
Comment on lines +933 to +938
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance conditional logic by using 'else if'

To improve clarity and avoid unnecessary checks, consider changing the second if to else if, since side cannot be both available and selection.

Apply this diff to implement the suggestion:

if (side == available) {
    updateSelection(item, Collections.emptySet(), true);
}
-if (side == selection) {
+else if (side == selection) {
    updateSelection(Collections.emptySet(), item, true);
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (side == available) {
updateSelection(item, Collections.emptySet(), true);
}
if (side == selection) {
updateSelection(Collections.emptySet(), item, true);
}
if (side == available) {
updateSelection(item, Collections.emptySet(), true);
}
else if (side == selection) {
updateSelection(Collections.emptySet(), item, true);
}

}
});
}
Expand Down
Loading