Skip to content

Commit

Permalink
fix(slim-select): add destroy method for slim-select objects that sho…
Browse files Browse the repository at this point in the history
…uld fix issue on macOs
  • Loading branch information
FlorentinTh committed Aug 9, 2023
1 parent 8e39210 commit a152be2
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/scripts/add-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,20 @@ const addNewAnalysis = async () => {
await writeData(dataValidated);
};

const destroySlimSelect = () => {
if (!(selectAntagonist === null)) {
selectAntagonist.destroy();
}

if (!(selectAgonist === null)) {
selectAgonist.destroy();
}

if (!(selectAngle === null)) {
selectAngle.destroy();
}
};

const writeData = async data => {
const messageLabel = setupType === 'muscles' ? setupType.slice(0, -1) : setupType;
loader.toggle({ message: `Saving new ${messageLabel}...` });
Expand Down Expand Up @@ -478,10 +492,12 @@ const writeData = async data => {
errorOverlay.show();
}

destroySlimSelect();
router.switchPage('data-configuration');
};

resetButton.addEventListener('click', event => {
destroySlimSelect();
router.switchPage('data-configuration');
});

Expand Down
2 changes: 2 additions & 0 deletions src/scripts/data-discovering.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ submitButton.addEventListener('click', async () => {

errorOverlay.show();
} else {
selectAnalysis.destroy();
router.switchPage('participants-selection');
}
} catch (error) {
Expand Down Expand Up @@ -658,6 +659,7 @@ submitButton.addEventListener('click', async () => {
errorOverlay.show();
}
} else {
selectAnalysis.destroy();
router.switchPage('data-discovering');
}
} else {
Expand Down
18 changes: 18 additions & 0 deletions src/scripts/edit-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,22 @@ const getAnalysisData = () => {
return new AnalysisModel(formData);
};

const destroySlimSelect = () => {
console.log('contentContainer' in elements);

if ('selectAntagonist' in elements) {
elements.selectAntagonist.destroy();
}

if ('selectAgonist' in elements) {
elements.selectAgonist.destroy();
}

if ('selectAngle' in elements) {
elements.selectAngle.destroy();
}
};

const updateData = async () => {
let model;

Expand Down Expand Up @@ -570,10 +586,12 @@ const updateData = async () => {
errorOverlay.show();
}

destroySlimSelect();
router.switchPage('data-configuration');
};

resetButton.addEventListener('click', event => {
destroySlimSelect();
router.switchPage('data-configuration');
});

Expand Down

0 comments on commit a152be2

Please sign in to comment.