question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Vue 3 timing issue with select control example for components (in this case @carbon/icons-vue icon)

See original GitHub issue

Describe the bug

The component is displayed if I refresh the browser, but not when selecting a story for a second time.

To Reproduce Steps to reproduce the behaviour:

  1. Create a simple component expecting an Icon component (using @carbon/vue-icons) e.g. a button
  2. Write your story along the lines of the icon example here https://storybook.js.org/docs/vue/essentials/controls
  3. View in the storybook.
  4. Change the story a few times and note the icon stops being displayed

Expected behavior Icon/Component should be displayed as expected.

Screenshots Icon no longer displayed after changing story from Primary to Secondary and back. image image image

Code snippets FAILING VERSION

import {
  Bee20,
  Carbon20,
  Watson20,
  IbmCloud20,
  EdtLoop20,
  IbmSecurity20,
} from '@carbon/icons-vue';

const icons = {
  Bee20,
  Carbon20,
  Watson20,
  IbmCloud20,
  EdtLoop20,
  IbmSecurity20,
};

export default {
  title: 'Components/CvIconButton',
  component: CvIconButton,
  argTypes: {
    icon: {
      control: {
        type: 'select',
        options: Object.keys(icons),
        value: 'Bee20',
      },
    },
  },
};

const Template = (args, { argTypes }) => {
  args.icon = icons[args.icon];
  return {
    props: Object.keys(argTypes),
    components: { CvIconButton },
    template: `<cv-icon-button v-bind="$props"/>`,
  };
};

export const Primary = Template.bind({});
export const Secondary = Template.bind({});
export const Tertiary = Template.bind({});

WORK AROUND - changed template to

const Template = (args, { argTypes }) => {
  return {
    props: Object.keys(argTypes),
    components: { CvIconButton },
    template: `<cv-icon-button :data-test="label" v-bind="$props" :icon="icon"/>`,
    setup(props) {
      const icon = shallowRef(icons[props.icon]);

      if (icon.value === undefined) {
        // assigning an icon seem sto need a kick
        setTimeout(() => {
          icon.value === icons[props.icon];
        }, 1);
      }

      return { icon };
    },
  };
};

System Please paste the results of npx sb@next info here.

$npx sb@next info

Environment Info:

System: OS: macOS 11.1 CPU: (12) x64 Intel® Core™ i7-8850H CPU @ 2.60GHz Binaries: Node: 14.15.3 - ~/.nvm/versions/node/v14.15.3/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.9 - ~/.nvm/versions/node/v14.15.3/bin/npm Browsers: Chrome: 88.0.4324.150 Edge: 88.0.705.63 Safari: 14.0.2 npmPackages: @storybook/addon-actions: ^6.2.0-alpha.24 => 6.2.0-alpha.24 @storybook/addon-essentials: ^6.2.0-alpha.24 => 6.2.0-alpha.24 @storybook/addon-links: ^6.2.0-alpha.24 => 6.2.0-alpha.24 @storybook/vue3: ^6.2.0-alpha.24 => 6.2.0-alpha.24

Additional context Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
jonniebigodescommented, Feb 16, 2021

@phated and @shilman i’ve been doing some testing and we could take the same approach as react js and ts

we could call the snippet your-component.vue3.js.mdx for vue 3 and your-component.vue2.js.mdx and you get the following in the docs:

example-vue2-vue3

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Bug]: Problems with Vue Library and Icons #11918 - GitHub
In my company, we have a library, that wrappers the carbon library for transferring a common style UI and for creating new UI...
Read more >
@carbon/icons-vue examples - CodeSandbox
Learn how to use @carbon/icons-vue by viewing and forking example apps that make use of @carbon/icons-vue on CodeSandbox.
Read more >
select and dropdown - Carbon Design System
The select component allows users to choose one option from a list. It is used in forms for users to submit data.
Read more >
v-select API - Vuetify
name type default #append‑icon string '$dropdown' #append‑outer‑icon string undefined #attach any false
Read more >
@carbon/icons-vue - npm
Vue components for icons in digital and software products using the Carbon Design System. Latest version: 10.49.1, last published: 9 months ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found