Skip to content

Commit

Permalink
fix: reset groupId in selectStory handler (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
sangonz193 authored Nov 19, 2020
1 parent 8d19b61 commit b176f73
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions addons/ondevice-knobs/src/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ export default class Panel extends React.Component {

channel.on(SET, this.setKnobs);
channel.on(SET_OPTIONS, this.setOptions);
channel.on(SELECT_STORY, this.reset);
channel.on(SELECT_STORY, this.selectStory);
channel.emit(FORCE_RE_RENDER);
}

componentWillUnmount() {
const { channel } = this.props;
channel.removeListener(SET, this.setKnobs);
channel.removeListener(SELECT_STORY, this.reset);
channel.removeListener(SELECT_STORY, this.selectStory);
}

onGroupSelect(name) {
Expand All @@ -77,6 +77,12 @@ export default class Panel extends React.Component {
channel.emit(RESET);
};

selectStory = () => {
const { channel } = this.props;
this.setState({ knobs: {}, groupId: DEFAULT_GROUP_ID });
channel.emit(RESET);
};

emitChange(changedKnob) {
const { channel } = this.props;
channel.emit(CHANGE, changedKnob);
Expand Down

0 comments on commit b176f73

Please sign in to comment.