Skip to content
Merged
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
15 changes: 11 additions & 4 deletions src/webcomponents/variant/family-genotype-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,16 @@ export default class FamilyGenotypeFilter extends LitElement {
}

// Update state on genotype change
async onSampleTableChange(e) {
onSampleTableChange(e) {
e.preventDefault();
const {gt, sampleId} = e.target.dataset;
// initialize the genotypes of this sample if not already in the state
if (!this.state[sampleId]) {
this.state[sampleId] = {
id: sampleId,
genotypes: []
};
}
if (e.target.checked) {
this.state[sampleId].genotypes.push(gt);
} else {
Expand All @@ -254,11 +261,10 @@ export default class FamilyGenotypeFilter extends LitElement {
}

// make sure the proband has at least 1 GT checked
this.errorState = !this.state[probandSampleId].genotypes.length ? "At least one genotype have to be selected for the proband." : false;
this.errorState = !this.state[probandSampleId]?.genotypes?.length ? "At least one genotype have to be selected for the proband." : false;
this.state = {...this.state};
this.noGtSamples = [...this.noGtSamples];
this.requestUpdate();
await this.updateComplete;
this.notifySampleFilterChange();
}

Expand Down Expand Up @@ -316,7 +322,8 @@ export default class FamilyGenotypeFilter extends LitElement {
<div class="form-check-label mode-button">
<select-field-filter
.data="${this.modeSelectData}"
value="${this.mode}"
.value="${this.mode}"
.forceSelection="${true}"
.config="${{
liveSearch: false,
multiple: false,
Expand Down
Loading