Skip to content

Commit

Permalink
Merge pull request #478 from Esri/fix-spatialReferenceChange-event
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeTschudi authored Jan 2, 2024
2 parents 8405b13 + cd6cd7a commit 79a896a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ describe('solution-spatial-ref', () => {
await page.waitForChanges();
await spatial_ref.setProperty('value', newSpatialRef);
await page.waitForChanges();
/*
expect(await spatial_ref.getProperty('value')).toBe(newSpatialRef);
*/

const solution_spatial_ref = await page.find('solution-spatial-ref');
expect(await solution_spatial_ref.getProperty('value')).toBe(newSpatialRef);
Expand Down
17 changes: 13 additions & 4 deletions src/components/spatial-ref/spatial-ref.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,20 @@ export class SpatialRef {

@Watch("value")
valueChanged(newValue: string): void {
this.spatialReferenceChange.emit({
oldValue: this.value,
newValue: newValue
});
this._spatialRef = this._createSpatialRefDisplay(newValue);
const searchBox = document.getElementById("calcite-sr-search") as HTMLCalciteInputElement;
if (searchBox) {
searchBox.value = this._srSearchText = "";
}
this._clearSelection();

if (this._cachedValue !== this.value) {
this.spatialReferenceChange.emit({
oldValue: this._cachedValue,
newValue: this.value
});
this._cachedValue = this.value;
}
}

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -117,6 +121,11 @@ export class SpatialRef {
//
//--------------------------------------------------------------------------

/**
* Holds a pre-change value of the wkid so that an event can be posted with the cached and new values.
*/
@State() protected _cachedValue = this.defaultWkid.toString();

/**
* Internal representation of component's value for display purposes.
*/
Expand Down

0 comments on commit 79a896a

Please sign in to comment.