Peter Holmberg 7 lat temu
rodzic
commit
db87c5126b

+ 6 - 0
public/app/plugins/panel/gauge/ValueMappings.test.tsx

@@ -51,4 +51,10 @@ describe('Next id to add', () => {
 
     expect(instance.state.nextIdToAdd).toEqual(4);
   });
+
+  it('should default to 1', () => {
+    const instance = setup({ options: { ...defaultProps.options } });
+
+    expect(instance.state.nextIdToAdd).toEqual(1);
+  });
 });

+ 1 - 1
public/app/plugins/panel/gauge/ValueMappings.tsx

@@ -16,7 +16,7 @@ export default class ValueMappings extends PureComponent<OptionModuleProps, Stat
 
     this.state = {
       mappings: mappings || [],
-      nextIdToAdd: mappings ? this.getMaxIdFromMappings(mappings) : 1,
+      nextIdToAdd: mappings.length > 0 ? this.getMaxIdFromMappings(mappings) : 1,
     };
   }