Skip to content

Conversation

Eng-Elias
Copy link
Contributor

Hello @jjti ,

I added some features to SeqViz to increase the ability to control events triggered from elements like bases, translations and annotations where you can pass onClick, onDoubleClick, onContextMenu and onHover, then you can check the type of element and do some action. I added some example how we can use these handlers.
I also added onKeyPress event handler if developer wants to set some custom keyboard shortcuts.
I think onHover event handler will help to display more details about elements.
onContextMenu and onKeyPress will be useful to build SeqViz editor not only a viewer.

Please review my changes and give me your opinion.
I am waiting to hear from you.

Thank you to consider my pull request.
@Eng-Elias

@rtviii
Copy link

rtviii commented Jul 27, 2025

@Eng-Elias any news here?

@Eng-Elias
Copy link
Contributor Author

I opened this pull request before about 2 years and asked for review but I didn't get any response, so I left it? @rtviii

@rtviii
Copy link

rtviii commented Jul 27, 2025

Good point! I assumed they are waiting for conflict resolution with mainline. But these on hover etc events would be quite useful to have.

@rtviii
Copy link

rtviii commented Jul 27, 2025

@jjti @guzmanvig any feedback for the samaritan above?

@Eng-Elias
Copy link
Contributor Author

Good point! I assumed they are waiting for conflict resolution with mainline. But these on hover etc events would be quite useful to have.

I am sorry but when I opened the PR, I ensured that there was no conflict then asked for the review.
Anyway, I can resolve the conflicts, if you want to merge this PR.

@rtviii
Copy link

rtviii commented Jul 27, 2025

Likewise, sorry, i just saw this last week. It's a shame the authors missed this back when you contributed.

@Eng-Elias
Copy link
Contributor Author

Likewise, sorry, i just saw this last week. It's a shame the authors missed this back when you contributed.

No problem, it is a small issue, let me know if you want anything from my side

@guzmanvig
Copy link
Collaborator

Hi @Eng-Elias, @rtviii ,

Apologies for the long silence on this PR — it slipped through the cracks.
Thanks a lot for contributing this feature!

If you’re still interested, could you please resolve the merge conflicts? Once that’s done, we’ll review it promptly and work on getting it merged.

Thanks!

@Eng-Elias
Copy link
Contributor Author

Done, I resolved the conflicts and fixed the tests
@guzmanvig @jjti @rtviii

Copy link
Collaborator

@guzmanvig guzmanvig left a comment

Choose a reason for hiding this comment

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

This is neat! I made some comments, but rejecting mainly because:

  • Seems like we are missing the functionality for Primers, Highlights and Translations. What I mean by that is that for example, clicking on a primer, highlight or translation doesn't trigger the onClick event.
  • Seems like these events are not supported in the circular view? Or at least they don't seem to work in the demo app.
  • Some ESLint errors. Really minor, like commented console.logs or not sorted arguments. You probably need to configure Eslint in your editor so it picks up the rules from .eslintrc.json

Thanks!

@@ -1,4 +1,6 @@
import * as React from "react";
import { Menu as ContextMenu, Item, Separator, Submenu, useContextMenu } from "react-contexify";
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Separator and Submenu are not being used, remove import.

import seqparse from "seqparse";
import tippy from "tippy.js";
import "tippy.js/dist/tippy.css";
import { TextSpan } from "typescript";
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This import is also not being used, remove import

Sidebar,
} from "semantic-ui-react";
import seqparse from "seqparse";
import tippy from "tippy.js";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason not to use the component for tooltips from Semantic UI (since it's already being used)? https://semantic-ui.com/modules/popup.html#/definition

});
};

handleContextMenuAddReverseTranslation = ({ event, props, triggerEvent, data }) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Could combine handleContextMenuAddForwardTranslation and handleContextMenuAddReverseTranslation into one function with an argument for the direction

id: CONTEXT_MENU_ID,
});

this.showContextMenu = show;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why creating it on line 120 to then re-assign it to what useContextMenu returns? Is this for the sake of renaming show?

highlights={[{ start: 0, end: 10 }]}
name={this.state.name}
onClick={(element, circular, linear, container) => {
// console.log({ element, circular, linear, container });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to also show the functionality of these other events. Could be as simple as a single tooltip for all that display some info of the event and what was clicked (like the one you did for annotations on hover)

<strong>Name</strong>: <span>${element.name}</span>
</div>
<div>
<strong>position</strong>: <span>[${element.start}-${element.end}]</span>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: Use capital P on position

</SeqViz>
)}
</div>
<footer>
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: add a small padding/margin on the left

event: React.MouseEvent<Element, MouseEvent>
) => void;
onDoubleClick?: (element: any, circular: boolean, linear: boolean, container: Element) => void;
onHover?: (element: any, hover: boolean, view: "LINEAR" | "CIRCULAR", container: Element) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason why onHover has a single paramview: "LINEAR" | "CIRCULAR" instead of circular: boolean, linear: boolean params like the others?

fullSeq: string;
inputRef: InputRefFunc;
lastBase: number;
onClick?: (element: any, circular: boolean, linear: boolean, container: Element) => void;
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: Would it be better to create a single prop typeeventHandlers: EventHandlers to avoid duplicating these types everywhere?

@Eng-Elias
Copy link
Contributor Author

I read your comments and I will work on them later because I am a little bit busy these days.
I actually opened this PR before 2 years and I didn't review the code when I resolved the conflicts that is why I am surprised of most comments because if I worked on this issue now, I wouldn't do most of those mistakes.

@guzmanvig
Copy link
Collaborator

I read your comments and I will work on them later because I am a little bit busy these days. I actually opened this PR before 2 years and I didn't review the code when I resolved the conflicts that is why I am surprised of most comments because if I worked on this issue now, I wouldn't do most of those mistakes.

Thanks @Eng-Elias! Just in cased you missed it, I emailed you (to the address in your Github profile) regarding your use case and other PRs you have open

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.

3 participants