From 4702db9c59f164b739accf1518cfa381f218cf3e Mon Sep 17 00:00:00 2001 From: Guzman Date: Tue, 16 Jan 2024 09:30:53 -0300 Subject: [PATCH 01/12] Checking that there is indeed a selection before scrolling --- src/SeqViewerContainer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index ed702acb7..e501db70f 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -93,7 +93,7 @@ class SeqViewerContainer extends React.Component { - if (this.props.selection?.start !== prevProps.selection?.start) { + if (this.props.selection?.start !== prevProps.selection?.start && this.props.selection?.start !== this.props.selection?.end) { this.setCentralIndex("LINEAR", this.props.selection?.start || 0); } }; From 6700c6fd69c6184dff032102a74633c3aeb8388a Mon Sep 17 00:00:00 2001 From: Guzman Date: Tue, 16 Jan 2024 09:34:40 -0300 Subject: [PATCH 02/12] Run prettier --- src/SeqViewerContainer.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index e501db70f..c079e112b 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -93,7 +93,10 @@ class SeqViewerContainer extends React.Component { - if (this.props.selection?.start !== prevProps.selection?.start && this.props.selection?.start !== this.props.selection?.end) { + if ( + this.props.selection?.start !== prevProps.selection?.start && + this.props.selection?.start !== this.props.selection?.end + ) { this.setCentralIndex("LINEAR", this.props.selection?.start || 0); } }; From b984f49bda390d8bd81c7d6b9f3a0bc26c8b9584 Mon Sep 17 00:00:00 2001 From: Guzman Date: Wed, 14 Feb 2024 11:37:11 -0300 Subject: [PATCH 03/12] Only scrolling if selection was done programatically --- src/SeqViewerContainer.tsx | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index c2f902810..8a85e2c66 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -46,11 +46,7 @@ interface SeqViewerContainerProps { rotateOnScroll: boolean; search: NameRange[]; selectAllEvent: (event: React.KeyboardEvent) => boolean; - selection?: { - clockwise?: boolean; - end: number; - start: number; - }; + selection?: Selection; seq: string; seqType: SeqType; showComplement: boolean; @@ -91,13 +87,16 @@ class SeqViewerContainer extends React.Component { - if ( - this.props.selection?.start !== prevProps.selection?.start && - this.props.selection?.start !== this.props.selection?.end - ) { - this.setCentralIndex("LINEAR", this.props.selection?.start || 0); + // Only scroll if the selection was done programatically, i.e.: has no type. + if (!this.props.selection?.type) { + if ( + this.props.selection?.start !== prevProps.selection?.start && + this.props.selection?.start !== this.props.selection?.end + ) { + this.setCentralIndex("LINEAR", this.props.selection?.start || 0); + } } }; @@ -135,11 +134,7 @@ class SeqViewerContainer extends React.Component { if (prop) { return { ...prop, clockwise: typeof prop.clockwise === "undefined" || !!prop.clockwise, type: "" }; From 8d40d64db91e733c930dea6473f80dbf424ac53b Mon Sep 17 00:00:00 2001 From: Guzman Date: Wed, 14 Feb 2024 11:39:08 -0300 Subject: [PATCH 04/12] Linter run --- src/SeqViewerContainer.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index 8a85e2c66..e22cecaa0 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -132,10 +132,7 @@ class SeqViewerContainer extends React.Component { + getSelection = (state: Selection, prop?: Selection): Selection => { if (prop) { return { ...prop, clockwise: typeof prop.clockwise === "undefined" || !!prop.clockwise, type: "" }; } From 3ad96e4a2497a390f6f1da8e6f9adec0914b483a Mon Sep 17 00:00:00 2001 From: Guzman Date: Wed, 14 Feb 2024 12:00:22 -0300 Subject: [PATCH 05/12] Implemented type guard for selection --- src/SeqViewerContainer.tsx | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index e22cecaa0..f0e71f016 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -46,7 +46,13 @@ interface SeqViewerContainerProps { rotateOnScroll: boolean; search: NameRange[]; selectAllEvent: (event: React.KeyboardEvent) => boolean; - selection?: Selection; + selection?: + | { + clockwise?: boolean; + end: number; + start: number; + } + | Selection; seq: string; seqType: SeqType; showComplement: boolean; @@ -87,10 +93,15 @@ class SeqViewerContainer extends React.Component { // Only scroll if the selection was done programatically, i.e.: has no type. - if (!this.props.selection?.type) { + // Check if props.selection is of Selection interface + if (this.selectionIsProgramatic(this.props.selection)) { if ( this.props.selection?.start !== prevProps.selection?.start && this.props.selection?.start !== this.props.selection?.end @@ -132,7 +143,16 @@ class SeqViewerContainer extends React.Component { + getSelection = ( + state: Selection, + prop?: + | { + clockwise?: boolean; + end: number; + start: number; + } + | Selection + ): Selection => { if (prop) { return { ...prop, clockwise: typeof prop.clockwise === "undefined" || !!prop.clockwise, type: "" }; } From 6f8a4dbe326d004c7450f32835ff2736ccadc1ed Mon Sep 17 00:00:00 2001 From: Guzman Date: Wed, 14 Feb 2024 12:04:54 -0300 Subject: [PATCH 06/12] Updated comments --- src/SeqViewerContainer.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index f0e71f016..ff949a60f 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -94,13 +94,13 @@ class SeqViewerContainer extends React.Component { - // Only scroll if the selection was done programatically, i.e.: has no type. - // Check if props.selection is of Selection interface + // Only scroll if the selection was done programatically if (this.selectionIsProgramatic(this.props.selection)) { if ( this.props.selection?.start !== prevProps.selection?.start && From 38b9f7dc7631e7b92b59081ab9f8b2e4c872845b Mon Sep 17 00:00:00 2001 From: Guzman Vigliecca <35040129+guzmanvig@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:16:56 -0500 Subject: [PATCH 07/12] Update src/SeqViewerContainer.tsx Co-authored-by: Joshua Timmons --- src/SeqViewerContainer.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index ff949a60f..8e8238be5 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -100,7 +100,8 @@ class SeqViewerContainer extends React.Component { - // Only scroll if the selection was done programatically + // Only scroll if the selection was done passed in as a prop by a user of SeqViz. Otherwise the selection was + // made by the user clicking an element or selecting a range of sequences if (this.selectionIsProgramatic(this.props.selection)) { if ( this.props.selection?.start !== prevProps.selection?.start && From b7ea117b1ec46f2216587c3c6413e0f93501a6d8 Mon Sep 17 00:00:00 2001 From: Guzman Date: Wed, 14 Feb 2024 13:19:17 -0300 Subject: [PATCH 08/12] Removed Selection type from props --- src/SeqViewerContainer.tsx | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index 8e8238be5..3c09bd12e 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -46,13 +46,11 @@ interface SeqViewerContainerProps { rotateOnScroll: boolean; search: NameRange[]; selectAllEvent: (event: React.KeyboardEvent) => boolean; - selection?: - | { - clockwise?: boolean; - end: number; - start: number; - } - | Selection; + selection?: { + clockwise?: boolean; + end: number; + start: number; + }; seq: string; seqType: SeqType; showComplement: boolean; From 3649075622602c96d2cc7263dceb2ddade69fc49 Mon Sep 17 00:00:00 2001 From: Guzman Date: Wed, 14 Feb 2024 13:49:49 -0300 Subject: [PATCH 09/12] Added ExternalSelection interface --- src/SeqViewerContainer.tsx | 19 +++---------------- src/SeqViz.tsx | 8 ++------ src/selectionContext.ts | 6 ++++++ 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index 3c09bd12e..9ccbddaeb 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -8,7 +8,7 @@ import SelectionHandler, { InputRefFunc } from "./SelectionHandler"; import CentralIndexContext from "./centralIndexContext"; import { Annotation, CutSite, Highlight, NameRange, Primer, Range, SeqType } from "./elements"; import { isEqual } from "./isEqual"; -import SelectionContext, { Selection, defaultSelection } from "./selectionContext"; +import SelectionContext, { ExternalSelection, Selection, defaultSelection } from "./selectionContext"; /** * This is the width in pixels of a character that's 12px @@ -46,11 +46,7 @@ interface SeqViewerContainerProps { rotateOnScroll: boolean; search: NameRange[]; selectAllEvent: (event: React.KeyboardEvent) => boolean; - selection?: { - clockwise?: boolean; - end: number; - start: number; - }; + selection?: ExternalSelection; seq: string; seqType: SeqType; showComplement: boolean; @@ -142,16 +138,7 @@ class SeqViewerContainer extends React.Component { + getSelection = (state: Selection, prop?: ExternalSelection): Selection => { if (prop) { return { ...prop, clockwise: typeof prop.clockwise === "undefined" || !!prop.clockwise, type: "" }; } diff --git a/src/SeqViz.tsx b/src/SeqViz.tsx index 78e2034e1..dc4982bad 100644 --- a/src/SeqViz.tsx +++ b/src/SeqViz.tsx @@ -18,7 +18,7 @@ import { } from "./elements"; import { isEqual } from "./isEqual"; import search from "./search"; -import { Selection } from "./selectionContext"; +import { ExternalSelection, Selection } from "./selectionContext"; import { complement, directionality, guessType, randomID } from "./sequence"; /** `SeqViz` props. See the README for more details. One of `seq`, `file` or `accession` is required. */ @@ -121,11 +121,7 @@ export interface SeqVizProps { * Externally managed selection. * * If passed, SeqViz uses this prop as the selection range, rather than the internally managed selection */ - selection?: { - clockwise?: boolean; - end: number; - start: number; - }; + selection?: ExternalSelection; /** a sequence to render. Can be DNA, RNA, or an amino acid sequence. Setting accession or file overrides this */ seq?: string; diff --git a/src/selectionContext.ts b/src/selectionContext.ts index 0c7e10dd3..1f957800c 100644 --- a/src/selectionContext.ts +++ b/src/selectionContext.ts @@ -27,6 +27,12 @@ export interface Selection { viewer?: "LINEAR" | "CIRCULAR"; } +export interface ExternalSelection { + clockwise?: boolean; + end: number; + start: number; +} + /** Initial/default selection */ export const defaultSelection: Selection = { clockwise: true, From 64bf6839b3b1c39a1c686bfdef77620989fc3e6e Mon Sep 17 00:00:00 2001 From: Guzman Date: Tue, 20 Feb 2024 11:15:33 -0300 Subject: [PATCH 10/12] 3.10.5 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f3f111c6b..c2141183f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "seqviz", - "version": "3.10.4", + "version": "3.10.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "seqviz", - "version": "3.10.4", + "version": "3.10.5", "license": "MIT", "dependencies": { "react-resize-detector": "^7.1.2", diff --git a/package.json b/package.json index 67fc3d882..e755d7596 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "seqviz", "description": "A viewer for DNA, RNA, and protein sequences that supports many input formats", - "version": "3.10.4", + "version": "3.10.5", "main": "dist/index.js", "types": "dist/index.d.ts", "unpkg": "dist/seqviz.min.js", From 348ecc97915f2aa5ae2f53b839a577d51ca0001f Mon Sep 17 00:00:00 2001 From: Guzman Date: Tue, 20 Feb 2024 16:43:20 -0300 Subject: [PATCH 11/12] Fixing bug when selection is undefined --- src/SeqViewerContainer.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SeqViewerContainer.tsx b/src/SeqViewerContainer.tsx index 9ccbddaeb..bb55e562c 100644 --- a/src/SeqViewerContainer.tsx +++ b/src/SeqViewerContainer.tsx @@ -89,7 +89,8 @@ class SeqViewerContainer extends React.Component Date: Tue, 20 Feb 2024 16:44:12 -0300 Subject: [PATCH 12/12] 3.10.6 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2141183f..d71c366c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "seqviz", - "version": "3.10.5", + "version": "3.10.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "seqviz", - "version": "3.10.5", + "version": "3.10.6", "license": "MIT", "dependencies": { "react-resize-detector": "^7.1.2", diff --git a/package.json b/package.json index e755d7596..256524b68 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "seqviz", "description": "A viewer for DNA, RNA, and protein sequences that supports many input formats", - "version": "3.10.5", + "version": "3.10.6", "main": "dist/index.js", "types": "dist/index.d.ts", "unpkg": "dist/seqviz.min.js",