CHANGE the detection of existingKnob so it just checks the type & name matches

if the name AND type match, it's very likely the same knob, checking the value was slower & caused and issue for me
when loading the value from url the first time. Open to other solutions too.
This commit is contained in:
Norbert de Langen 2019-04-10 23:45:29 +02:00
parent 4addccc21a
commit 42b26cf9af

View File

@ -1,5 +1,4 @@
/* eslint no-underscore-dangle: 0 */
import deepEqual from 'fast-deep-equal';
import escape from 'escape-html';
import { getQueryParams } from '@storybook/client-api';
@ -63,7 +62,7 @@ export default class KnobManager {
// We need to return the value set by the knob editor via this.
// But, if the user changes the code for the defaultValue we should set
// that value instead.
if (existingKnob && deepEqual(options.value, existingKnob.defaultValue)) {
if (existingKnob && options.type === existingKnob.type) {
return this.getKnobValue(existingKnob);
}