Skip to content

Commit

Permalink
Fixed bug with Excel Logic that prevented event listeners being added.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnman committed Jan 23, 2024
1 parent 815bb06 commit 2d756bf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions how-to/integration-excel/client/src/excel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,15 @@ async function populateWorksheets(): Promise<void> {
* @param name The name of worksheet to select.
*/
async function selectWorksheet(name: string): Promise<void> {
if (openWorksheets && selectedWorksheetIndex !== undefined) {
if (openWorksheets && selectedWorksheetIndex === undefined) {
const newWorksheetIndex = openWorksheets.findIndex((w) => w.name === name);

if (newWorksheetIndex !== selectedWorksheetIndex) {
const oldWorksheet = openWorksheets[selectedWorksheetIndex];
if (oldWorksheet) {
await oldWorksheet.sheet.removeEventListener(handleCellChange);
if(selectedWorksheetIndex !== undefined) {
const oldWorksheet = openWorksheets[selectedWorksheetIndex];
if (oldWorksheet) {
await oldWorksheet.sheet.removeEventListener(handleCellChange);
}
}

selectedWorksheetIndex = newWorksheetIndex;
Expand Down
4 changes: 2 additions & 2 deletions how-to/integration-excel/public/manifest.fin.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"snapshot": {
"windows": [
{
"defaultWidth": 600,
"defaultHeight": 600,
"defaultWidth": 800,
"defaultHeight": 900,
"defaultLeft": 0,
"defaultTop": 0,
"saveWindowState": false,
Expand Down

0 comments on commit 2d756bf

Please sign in to comment.