Dashboards: Edit pane variable unique key (#107212)

* Dashboards: Edit pane unique key

* lint

* Update public/app/features/dashboard/components/PanelEditor/OptionsPaneItemDescriptor.tsx

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>

* lint

---------

Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
Scott Lepper 2025-07-28 01:49:38 -04:00 committed by GitHub
parent 910454c84c
commit 713c9921ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import { css } from '@emotion/css';
import { uniqueId } from 'lodash';
import { ReactNode } from 'react';
import * as React from 'react';
import Highlighter from 'react-highlight-words';
@ -31,11 +32,17 @@ export interface OptionsPaneItemInfo {
*/
export class OptionsPaneItemDescriptor {
parent!: OptionsPaneCategoryDescriptor;
props: OptionsPaneItemInfo;
constructor(public props: OptionsPaneItemInfo) {}
constructor(props: OptionsPaneItemInfo) {
this.props = { ...props, id: props.id ?? props.title };
if (this.props.id === '') {
this.props.id = uniqueId();
}
}
render(searchQuery?: string) {
return <OptionsPaneItem key={this.props.title} itemDescriptor={this} searchQuery={searchQuery} />;
return <OptionsPaneItem key={this.props.id} itemDescriptor={this} searchQuery={searchQuery} />;
}
useShowIf() {