Skip to content

Conversation

@Morris-Zin
Copy link

Fixes #414

Clicking on a row in Cluster/Peer Overview now navigates to the respective configurator while taking into account of user selecting texts.

  • Uses mouse distance to solve text selection case (< 5px = click, ≥ 5px = drag)
  • No new dependencies added

@Morris-Zin Morris-Zin changed the base branch from main to development January 19, 2026 19:27
Copy link
Contributor

@mbfm mbfm left a comment

Choose a reason for hiding this comment

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

Hi, thanks for opening another pull request! 🙂

Generally, the changes look reasonable, but it's best to avoid code duplication where reasonably possible. It adds a lot of maintenance overhead when the different code replicas start diverging over time...

Comment on lines +25 to +31
let cluster_id = create_read_slice(cluster_descriptor, |cluster_descriptor| {
cluster_descriptor.id
});

let cluster_id = create_read_slice(cluster_descriptor,
|cluster_descriptor| {
cluster_descriptor.id
}
);

let cluster_name = create_read_slice(cluster_descriptor,
|cluster_descriptor| {
Clone::clone(&cluster_descriptor.name).to_string()
}
);
let cluster_name = create_read_slice(cluster_descriptor, |cluster_descriptor| {
Clone::clone(&cluster_descriptor.name).to_string()
});
Copy link
Contributor

@mbfm mbfm Jan 20, 2026

Choose a reason for hiding this comment

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

If you use a formatter, could you please set it, so that it only formats the lines that you actually modified, please? It makes it difficult to review what you actually changed, is more likely to lead to merge/rebase conflicts and some of the automatic formatting changes are less readable than hand-formatted code...

Comment on lines +64 to +69
let (start_x, start_y) = mousedown_pos.get();
let (end_x, end_y) = (e.client_x(), e.client_y());
let diff_x = (end_x - start_x) as f64;
let diff_y = (end_y - start_y) as f64;
// euclidean distance formula -> distance = sqrt(diff_x² + diff_y²)
let distance = (diff_x * diff_x + diff_y * diff_y).sqrt();
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you pull this out into a function in util, which calculates this distance?

Maybe so that it can be called like so:

Suggested change
let (start_x, start_y) = mousedown_pos.get();
let (end_x, end_y) = (e.client_x(), e.client_y());
let diff_x = (end_x - start_x) as f64;
let diff_y = (end_y - start_y) as f64;
// euclidean distance formula -> distance = sqrt(diff_x² + diff_y²)
let distance = (diff_x * diff_x + diff_y * diff_y).sqrt();
let distance = calculate_distance(mousedown_pos.get(), (e.client_x(), e.client_y()));

let diff_y = (end_y - start_y) as f64;
// euclidean distance formula -> distance = sqrt(diff_x² + diff_y²)
let distance = (diff_x * diff_x + diff_y * diff_y).sqrt();
if distance < 5.0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you pull out this 5.0 into a constant, maybe also into util for now, e.g. MOUSE_DRAG_PIXEL_THRESHOLD.

It would also be good to add a short comment here, to say that we're doing this to fix text selection. Generally, we prefer readable code over comments, but the why cannot easily be expressed in code.

@Morris-Zin
Copy link
Author

hi @mbfm , thanks for the detailed review and the helpful suggestions. I'll get to work on implementing the above suggestions.

@mbfm
Copy link
Contributor

mbfm commented Jan 20, 2026

I also noticed that it doesn't work in the PeerOverview, seemingly when clicking on the "Configured in Clusters" column, e.g. in these positions:

image

Maybe there's a call to e.stop_propagation() missing for those elements?

@Morris-Zin
Copy link
Author

thanks for pointing out, i will try to debug this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rows in tables should be clickable

2 participants