grafana / iot-sitewise-datasource

IoT Sitewise
Apache License 2.0
18 stars 9 forks source link

fix: clear selected property when assets are removed #278

Closed tracy-french closed 8 months ago

tracy-french commented 8 months ago

Which issue(s) this PR fixes: https://github.com/grafana/iot-sitewise-datasource/issues/273

CLAassistant commented 8 months ago

CLA assistant check
All committers have signed the CLA.

tracy-french commented 8 months ago

Hi @tracy-french, thanks for the PR. It works when the old form styling is used, but not with the new form style (when the feature toggle newFormStylingEnabled = true).

I believe you'd just need to add ?? null to the value prop to the "Property" select component in the newFormStylingEnabled branch of the render function on line 442.

<Select
  id="property"
  aria-label="Property"
  isLoading={loading}
  options={properties}
  value={currentProperty ?? null} // <-----
  onChange={this.onPropertyChange}
  placeholder="Select a property"
  allowCustomValue={true}
  isSearchable={true}
  onCreateOption={this.onSetPropertyId}
  formatCreateLabel={(txt) => `Property ID: ${txt}`}
  menuPlacement="bottom"
/>

Thank you, @kevinwcyu! I'll make the change.

tracy-french commented 8 months ago

@kevinwcyu Updated!