Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Color-Picker Not Rendering in Vue JS #4481

Closed
joeyHarig opened this issue May 3, 2022 · 7 comments
Closed

Bug: Color-Picker Not Rendering in Vue JS #4481

joeyHarig opened this issue May 3, 2022 · 7 comments
Assignees
Labels
4 - verified Issues that have been released and confirmed resolved. bug Bug reports for broken functionality. Issues should include a reproduction of the bug.

Comments

@joeyHarig
Copy link
Contributor

joeyHarig commented May 3, 2022

Actual Behavior

The calcite-color-picker component doesn not render within a Vue application. When attempting to use the color-picker, the following error occurrs:

Screen Shot 2022-05-02 at 8 48 21 PM

This error is only persistent in the latest version of the software 1.0.0-beta.81. When reverting to 1.0.0-beta.80, the color-picker component renders fine.

Expected Behavior

The calcite-color-picker should render within Vue apps.

Reproduction Sample

https://github.com/joeyHarig/cc-vue-color-picker-bug

Reproduction Steps

  1. Fork the above repo
  2. Run npm install
  3. Run npm run serve
  4. Open up the App.vue file to validate that the calcite-date-picker, calcite-color-picker, and calcite-button are included in the markup.
  5. View the application on port http://localhost:8080/
  6. Notice that the color picker component doesn't render.
  7. Open the dev tools console to view the error message "TypeError: Cannot use 'in' operator to search for '0' in rgb
    at __spreadArray"

Reproduction Version

1.0.0-beta.81

Relevant Info

Browser: Chrome, Firefox
OS: macOS Monterey

Using Stencil within a Vue App: https://stenciljs.com/docs/vue

Regression?

1.0.0-beta.80

@joeyHarig joeyHarig added 0 - new New issues that need assignment. bug Bug reports for broken functionality. Issues should include a reproduction of the bug. needs triage Planning workflow - pending design/dev review. labels May 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented May 3, 2022

More information is required to proceed with this issue:

This issue will be automatically closed in five days if the information is not provided. Thanks for your understanding.

@github-actions github-actions bot added the incomplete issue report New issues missing important information, and unless provided, they will be closed after 5 days. label May 3, 2022
@joeyHarig joeyHarig changed the title Bug: Vue JS Color-Picker not Rendering Bug: Color-Picker Not Rendering in Vue JS May 3, 2022
@macandcheese
Copy link
Contributor

I'm also seeing this error with CalciteColorPickerHexInput and CalciteColorPickerSwatch locally in React (Gatsby).

It occurs using when using either the vanilla component or the wrapped React version:

Screen Shot 2022-05-03 at 8 55 26 AM

@benelan benelan removed the incomplete issue report New issues missing important information, and unless provided, they will be closed after 5 days. label May 4, 2022
@benelan benelan added this to the Sprint 05/09 - 05/20 milestone May 6, 2022
@benelan benelan removed the needs triage Planning workflow - pending design/dev review. label May 6, 2022
@Elijbet Elijbet assigned Elijbet and jcfranco and unassigned Elijbet May 11, 2022
@jcfranco jcfranco added 2 - in development Issues that are actively being worked on. and removed 0 - new New issues that need assignment. labels May 16, 2022
@jcfranco
Copy link
Member

TL;DR - the reported error is caused by a tslib bug (used by Stencil build) + color lint fix that made it run into the aforementioned bug. See potential fixes near the end.

I looked into this today and here are some findings:

Solutions

  • As a current workaround for Vue (and possibly other environments), the build config can be updated to specify the mainFields to use any of the following esm entry point files ("es2017", "es2015", "jsnext:main"):

    // vue.config.js
    module.exports = {
      chainWebpack: (config) => {
        //...
      
        config.resolve.mainFields
          .merge(["es2017", "browser", "module", "main"]);
      }
    };

    Note: there could be other ways of specifying this, but this is what ended up working for me with the repro case.

  • For the tslib bug, I've submitted a PR. If it gets merged, the next step would be to see if we can get the Stencil build to use the latest version.

  • We'd have to look into this beforehand, but we could also update our module entry from package.json to point to dist/esm/index.js.

  • Worst case scenario, and I'd really like to avoid this, we could revert build(deps): bump color from 4.2.1 to 4.2.3 #4381 and build: remove unnecessary numeric separator plugin #4385 to use a version of color that wouldn't run into this issue.

@jcfranco
Copy link
Member

We'd have to look into this beforehand, but we could also update our module entry from package.json to point to dist/esm/index.js.

@benelan Let's sync up on this tomorrow to see if we can make the switch.

@jcfranco
Copy link
Member

Ended up patching __spreadArray instead of switching the default module entry to minimize impact to builds using this output.

@jcfranco jcfranco added 3 - installed Issues that have been merged to master branch and are ready for final confirmation. and removed 2 - in development Issues that are actively being worked on. labels May 18, 2022
@github-actions github-actions bot assigned benelan and geospatialem and unassigned jcfranco May 18, 2022
@github-actions
Copy link
Contributor

Installed and assigned for verification.

@geospatialem geospatialem added 4 - verified Issues that have been released and confirmed resolved. and removed 3 - installed Issues that have been merged to master branch and are ready for final confirmation. labels May 26, 2022
@geospatialem
Copy link
Member

Verified in 1.0.0-next.478

color picker rendering in vue with 1.0.0-next.478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - verified Issues that have been released and confirmed resolved. bug Bug reports for broken functionality. Issues should include a reproduction of the bug.
Projects
None yet
Development

No branches or pull requests

6 participants