Skip to content

Addons panel position resets on story change #6114

Open

Description

Describe the bug
Panel position is being reset to what is specified in the global options.

To Reproduce
Steps to reproduce the behavior:

  1. Run CRA example (note: panelPosition: 'right' is set in the options)
  2. Open /?path=/story/button--with-text
  3. Switch addons panel to the bottom mode
  4. Open /?path=/story/button--with-some-emoji
  5. Addons panel position is reset to the right mode

Expected behavior
Addons panel should be still displayed in the bottom.

Code snippets
Looks like the problem is here:

// lib/ui/src/core/context.js
api.on(STORY_CHANGED, id => {
  const options = api.getParameters(id, 'options');

  api.setOptions(options);
});
// lib/ui/src/core/layout.js
const updatedLayout = {
  ...layout,
  ...pick(options, Object.keys(layout)),
  ...checkDeprecatedLayoutOptions(options),
};

setOptions is being called after every story change, and panelPosition is being reset to what is specified in the options, as ...pick(options, Object.keys(layout)), overrides whatever is in layout.

System:

  • OS: MacOS
  • Device: Macbook Pro 2015
  • Browser: chrome
  • Framework: react
  • Version: 5.1.0-alpha.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions