Skip to content

Commit

Permalink
Fixed reported bug about console errors (#2095)
Browse files Browse the repository at this point in the history
# Pull Request

## 🤨 Rationale

[Bug
2671736](https://dev.azure.com/ni/DevCentral/_workitems/edit/2671736):
Wafermap plugin logs unnecessary info to the console.

The bug mentioned above was fixed.

## 👩‍💻 Implementation

Resize changes sometimes do not propagate correctly when the component
is initialized, so the hover rect gets 'NaN' values for height and
width.
Checked the dimensions before setting them.

## 🧪 Testing

Existing tests are passing.
New test added.

## ✅ Checklist

<!--- Review the list and put an x in the boxes that apply or ~~strike
through~~ around items that don't (along with an explanation). -->

- [x] I have updated the project documentation to reflect my changes or
determined no changes are needed.

---------

Co-authored-by: Milan Raj <rajsite@users.noreply.github.com>
  • Loading branch information
munteannatan and rajsite authored May 13, 2024
1 parent 8049945 commit dee0ac1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Fixed hover die template error where width and height were NaN",
"packageName": "@ni/nimble-components",
"email": "33986780+munteannatan@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ export class Computations {
gridDimensions,
containerDiameter
);
const dieWidth = this.horizontalScale.bandwidth();
const dieHeight = this.verticalScale.bandwidth();
this._dieDimensions = {
width: this.horizontalScale.bandwidth(),
height: this.verticalScale.bandwidth()
width: isNaN(dieWidth) ? 0 : dieWidth,
height: isNaN(dieHeight) ? 0 : dieHeight
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ export class WorkerRenderer {
}

public renderHover(): void {
if (
this.wafermap.experimentalDataManager.dieDimensions === undefined
|| this.wafermap.transform === undefined
) {
return;
}
this.wafermap.hoverWidth = this.wafermap.experimentalDataManager.dieDimensions.width
* this.wafermap.transform.k;
this.wafermap.hoverHeight = this.wafermap.experimentalDataManager.dieDimensions.height
Expand Down
6 changes: 6 additions & 0 deletions packages/nimble-components/src/wafer-map/modules/rendering.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export class RenderingModule {
}

public renderHover(): void {
if (
this.wafermap.dataManager.dieDimensions === undefined
|| this.wafermap.transform === undefined
) {
return;
}
this.wafermap.hoverWidth = this.wafermap.dataManager.dieDimensions.width
* this.wafermap.transform.k;
this.wafermap.hoverHeight = this.wafermap.dataManager.dieDimensions.height
Expand Down
23 changes: 18 additions & 5 deletions packages/nimble-components/src/wafer-map/tests/wafer-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('WaferMap', () => {
);
});

describe('update flow', () => {
describe('update action', () => {
let spy: jasmine.Spy;
beforeEach(() => {
spy = spyOn(element, 'update');
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('WaferMap', () => {
});
});

describe('worker renderer draw flow', () => {
describe('worker renderer draw action', () => {
let setupWaferSpy: jasmine.Spy;
let drawWaferSpy: jasmine.Spy;
beforeEach(() => {
Expand Down Expand Up @@ -151,7 +151,7 @@ describe('WaferMap', () => {
});
});

describe('worker renderer flow', () => {
describe('worker renderer action', () => {
let renderHoverSpy: jasmine.Spy;
let experimentalUpdateSpy: jasmine.Spy;

Expand Down Expand Up @@ -194,7 +194,7 @@ describe('WaferMap', () => {
});
});

describe('zoom flow', () => {
describe('zoom action', () => {
let initialValue: string | undefined;

beforeEach(() => {
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('WaferMap', () => {
return element.transform.toString();
}

describe('hover flow', () => {
describe('hover action', () => {
beforeEach(async () => {
element.canvasWidth = 500;
element.canvasHeight = 500;
Expand Down Expand Up @@ -321,4 +321,17 @@ describe('WaferMap', () => {
expect(element.hoverTransform).not.toEqual(initialTransform);
});
});

describe('hover action with no canvas dimensions', () => {
beforeEach(async () => {
element.dies = [{ x: 1, y: 1, value: '1' }];
element.colorScale = { colors: ['red', 'red'], values: ['1', '1'] };
await waitForUpdatesAsync();
});

it('will have hover rectangle with no dimensions', () => {
expect(element.hoverHeight).toEqual(0);
expect(element.hoverWidth).toEqual(0);
});
});
});

0 comments on commit dee0ac1

Please sign in to comment.