Skip to content

Commit

Permalink
Merge pull request #30 from TeselaGen/tnwAddAdditionalNullPointerChecks
Browse files Browse the repository at this point in the history
adding more null pointer checks for tgSelect, making annotation start…
  • Loading branch information
tnrich authored Sep 18, 2023
2 parents 6268040 + cd60e0f commit 292d7db
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/sequence-utils/src/tidyUpAnnotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ function coerceLocation({
" and set to size: " +
size
); //setting it to 0 internally, but users will see it as 1
location.start = size - (isProtein ? 3 : 1);
location.start = Math.max(0, size - (isProtein ? 3 : 1));
}
if (
location.end < 0 ||
Expand All @@ -172,7 +172,7 @@ function coerceLocation({
" and set to seq size: " +
size
); //setting it to 0 internally, but users will see it as 1
location.end = size - 1;
location.end = Math.max(0, size - 1);
}
if (location.start > location.end && circular === false) {
messages.push(
Expand Down
6 changes: 3 additions & 3 deletions packages/ui/src/FormComponents/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ export const renderReactSelect = props => {
}
} else if (Array.isArray(value)) {
valueToUse = value.map(val => {
if (val.userCreated) {
if (val?.userCreated) {
return {
label: val.value,
value: val
Expand All @@ -719,10 +719,10 @@ export const renderReactSelect = props => {
let valToPass;
if (Array.isArray(valOrVals)) {
valToPass = valOrVals.map(function (val) {
if (val.userCreated) {
if (val?.userCreated) {
return val;
}
return val.value;
return val?.value;
});
} else if (valOrVals) {
if (valOrVals.userCreated) {
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/src/TgSelect/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class TgSelect extends React.Component {
) {
const topLevelId = item.value.split(":")[0];
valArray = valArray.filter(val => {
if (val.value && val.value.includes && val.value.includes(":")) {
if (val?.value && val.value.includes && val.value.includes(":")) {
const valId = val.value.split(":")[0];
if (valId === topLevelId) {
return false;
Expand Down Expand Up @@ -187,7 +187,7 @@ class TgSelect extends React.Component {
getTagProps = label => {
const { multi, value = [], disabled: _disabled } = this.props;
const val = Array.isArray(value) ? value : [value];
const matchingVal = val.find(op => op.label === label);
const matchingVal = val.find(op => op?.label === label);
const disabled = _disabled || (matchingVal && matchingVal.disabled);
const className = matchingVal && matchingVal.className;

Expand Down

0 comments on commit 292d7db

Please sign in to comment.