Comments (18)
Team work!!!
from coloris.
Pretty sure that this fixed it, as we had no updates within this bundle for months. I will try to deliver the latest coloris version to some test users in our next development cycle and provide you the bundled code and logs, if it occures again
from coloris.
@laura-perbility Do you also use Coloris as an NPM module?
from coloris.
It seems that the error just occured because I had the habbit to start the browser first and the devserver afterwards.
I was finally able to reproduce the error thanks to this clue. It appears that when firefox starts, it triggers input
and change
events on all the fields on the page (not quite sure why!), which causes a race condition in Coloris.
I'm going to release a fix in a few moments. thank you @laura-perbility and @rintisch for you help to identify this issue.
from coloris.
@mdbassit I wonder if its a bug in our Coloris Wrapper doing something slightly differently as it has to load for loaders.
I suspected that at first, but @laura-perbility says they are getting the error with the official build of Coloris rather than the npm version.
Either way, I'll take a look at the code of both to see if I can spot something.
from coloris.
@mdbassit I will come back with a minimal version of my code that I can share as soon as possible, hopefully this weekend.
from coloris.
Thank you for reporting this ! If this is indeed a yet unfixed issue, I'd like to get to the bottom of it. Initializing colorAreaDims with its properties will just mask any underlying problem. Would you be willing to share more information about your logs ?
Does this happen with other browsers or other versions of Firefox ?
Are there any more details you can share from your logs ? What properties are being accessed while colorAreaDims is still undefined ?
from coloris.
I will try to summarize:
- most of our customers use Firefox esr 102, but I found some error logs with Firefox 113, no other browser except firefox
- I tried to reproduce it with Firefox 113 but hat no success
That is our config
Coloris({
el: '.color-input',
focusInput: true,
alpha: false,
swatches: []
});
We currently use the 0.20.0 version in production, it also appeared in 0.19.0 (dist files)
s is undefined
M (https://lib.js?v140.0:7:7061)
j (https://lib.js?v140.0:7:9349)
a is undefined
B (https://lib.js?v139.1:7:7219)
z (https://lib.js?v139.1:7:9129)
The error occured on initial page load or something, not while using the picker. I have no info about user input, but am sure that the picker was not visible or used.
So I checked the code and s/a being undefined had to be the colorAreaDims while trying to access its width, somehow trying to set a marker
Hope that helps
from coloris.
This is quite a bit tricky!
colorAreaDims is defined the moment the document finishes loading. I can't imagine how it can be accessed before it's defined! Are you certain the s/a minified names are indeed colorAreaDims?
Also, it looks like you are using Coloris as part of a bundle, are you certain the error comes from Coloris and not some other tool in the bundle? Is it at all possible to have a copy of the bundle to examine ?
from coloris.
I will try to deliver the latest coloris version to some test users in our next development cycle and provide you the bundled code and logs, if it occures again
Thank you so much ! With your help, we can make Coloris better for everyone.
from coloris.
I get the same error, also in Firefox (116.0.1). I am currently only working local and there the error occurs only after starting the dev on the first page load. If I restart the devserver again and reload the page the error does not occur O.o
I post a snippet of my package.json
, maybe it helps?
{
"scripts": {
"devserver": "npx webpack serve"
},
"dependencies": {
"@melloware/coloris": "^0.20.0",
"@svgdotjs/svg.js": "^3.1.2"
},
"devDependencies": {
"sass": "^1.64.1",
"sass-loader": "^13.3.2",
"css-loader": "^6.8.1",
"eslint": "^8.45.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.27.5",
"style-loader": "^3.3.3",
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
}
}
And here is how I use it: I need multiple palettes next to each other, therefore I created the needed HTML elements myself. I guess this is not best practice but to be honest I did not get it from the documentation but just looked at the example page and imitated it.
#renderColorPalette(data) {
Coloris.init();
const paletteContainer = document.getElementById('color-palette');
// palette is an array of HEX colors
const palette = data.colors.palette;
palette.forEach((color, i) => {
// Container div
let container = this.htmlElements.container(['color-container', 'clr-field']);
container.style.color = color;
// Create input field
let input = this.htmlElements.input(
'text', `color-${i}`, color
);
// Following line seems to be needed to make it work, but is not documented so I think I do it not the right way?
input.setAttribute('data-coloris', '');
input.addEventListener('change', event => { // some event listener});
container.appendChild(input);
// Create button
let button = document.createElement('button');
container.appendChild(button);
Coloris.setInstance(`color-${i}`, {
alpha: false,
format: 'hsl',
});
paletteContainer.appendChild(container);
});
}
from coloris.
I get the same error, also in Firefox (116.0.1). I am currently only working local and there the error occurs only after starting the dev on the first page load. If I restart the devserver again and reload the page the error does not occur O.o
Can you paste the exact error message you get?
And here is how I use it: I need multiple palettes next to each other, therefore I created the needed HTML elements myself. I guess this is not best practice but to be honest I did not get it from the documentation but just looked at the example page and imitated it.
You don't need to define most of that manually, all you need is to generate your input fields and then initialize Coloris.
// Not sure what JS framework you use, so I'm reusing your code style
#renderColorPalette(data) {
Coloris.init();
const paletteContainer = document.getElementById('color-palette');
// palette is an array of HEX colors
const palette = data.colors.palette;
palette.forEach((color, i) => {
// Create input field
const input = this.htmlElements.input(
'text', `color-${i}`, color
);
input.setAttribute('data-coloris', '');
paletteContainer.appendChild(input);
});
Coloris({
alpha: false,
format: 'hsl',
});
}
from coloris.
@mdbassit here is the exact error message:
Uncaught TypeError: colorAreaDims is undefined
setColorAtPosition webpack:///./node_modules/@melloware/coloris/dist/esm/coloris.js?:576
setHue webpack:///./node_modules/@melloware/coloris/dist/esm/coloris.js?:733
Thanks for caring!
from coloris.
@mdbassit we take the dist build and use webpack to bundle it with other libraries. It is loaded via
<script src="/build/lib.js?v141.3" type="text/javascript" defer=""></script>
like
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["lib"], { (function(module, exports) { // Coloris dist build or other library } }
from coloris.
@mdbassit I wonder if its a bug in our Coloris Wrapper doing something slightly differently as it has to load for loaders.
from coloris.
I'm still unable to reproduce this error nor find anything that might cause it!
@rintisch, is it at all possible for you to share your code so I can't try and diagnose this a bit more?
from coloris.
@mdbassit I created a nearly minimal setup of my app. You can find it here:
https://github.com/rintisch/coloris-issue-117
But as I realized now: The error seems only to occur when I did not yet start the devserver (npm run devserver
). So it is in my case not a bug would I say. It seems that the error just occured because I had the habbit to start the browser first and the devserver afterwards.
from coloris.
@mdbassit I had one test user reproducing it with latest coloris version that resulted in the following bundled code. He reported explicitly no error or interaction with the picker itself while the log was generated.
s is undefined
M (https://app/lib.js?v142.0-rc01+20230818-115702+test:7:7116)
j (https://app/lib.js?v142.0-rc01+20230818-115702+test:7:9404) 2023-08-21 10:13:14.137 6316F799 Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0 [1022,730] [1536,864]
Bundled code
(window.webpackJsonp = window.webpackJsonp || []).push([["lib"], { "1/hh": function (e, t) { /*! * Copyright (c) 2021 Momo Bassit. * Licensed under the MIT License (MIT) * https://github.com/mdbassit/Coloris */ !function (e, t, n, i) { var o, r, a, s, l, c, d, u, h, f, m, g, p, E, T, C, I, O = t.createElement("canvas").getContext("2d"), v = { r: 0, g: 0, b: 0, h: 0, s: 0, v: 0, a: 1 }, D = { el: "[data-coloris]", parent: "body", theme: "default", themeMode: "light", rtl: !1, wrap: !0, margin: 2, format: "hex", formatToggle: !1, swatches: [], swatchesOnly: !1, alpha: !0, forceAlpha: !1, focusInput: !0, selectInput: !1, inline: !1, defaultColor: "#000000", clearButton: !1, clearLabel: "Clear", closeButton: !1, closeLabel: "Close", onChange: function () { }, a11y: { open: "Open color picker", close: "Close color picker", clear: "Clear the selected color", marker: "Saturation: {s}. Brightness: {v}.", hueSlider: "Hue slider", alphaSlider: "Opacity slider", input: "Color value field", format: "Color format", swatch: "Color swatch", instruction: "Saturation and brightness selector. Use up, down, left and right arrow keys to select." } }, R = {}, b = "", y = {}, K = !1; function _(n) { if ("object" == typeof n) for (var i in n) switch (i) { case "el": x(n.el), !1 !== n.wrap && A(n.el); break; case "parent": (o = t.querySelector(n.parent)) && (o.appendChild(r), D.parent = n.parent, o === t.body && (o = void 0)); break; case "themeMode": D.themeMode = n.themeMode, "auto" === n.themeMode && e.matchMedia && e.matchMedia("(prefers-color-scheme: dark)").matches && (D.themeMode = "dark"); case "theme": n.theme && (D.theme = n.theme), r.className = "clr-picker clr-" + D.theme + " clr-" + D.themeMode, D.inline && N(); break; case "rtl": D.rtl = !!n.rtl, t.querySelectorAll(".clr-field").forEach((function (e) { return e.classList.toggle("clr-rtl", D.rtl) })); break; case "margin": n.margin *= 1, D.margin = isNaN(n.margin) ? D.margin : n.margin; break; case "wrap": n.el && n.wrap && A(n.el); break; case "formatToggle": D.formatToggle = !!n.formatToggle, G("clr-format").style.display = D.formatToggle ? "block" : "none", D.formatToggle && (D.format = "auto"); break; case "swatches": Array.isArray(n.swatches) && function () { var e = []; n.swatches.forEach((function (t, n) { e.push('' + t + "") })), G("clr-swatches").innerHTML = e.length ? "from coloris.
Related Issues (20)
- Open method HOT 3
- clr-open-label not initialized on osX HOT 4
- Add 'Cancel' button (or any custom button) HOT 5
- Materializecss compatibility HOT 2
- Popup Input Issue HOT 3
- Mouse does not lineup on palette after scrolling in scrollable container HOT 3
- Include SCSS file with variables HOT 10
- Add support for CSS custom properties (variables) HOT 1
- Colorpicker wraps all input fields on page load HOT 6
- I would like to contribute sass/scss to the repository HOT 4
- ARIA: issue with Inline `#clr-color-marker` HOT 6
- Incorrect output value of alpha channel in 8-digit Hex Code HOT 8
- The color picker doesn't stick to the input it scrolls along HOT 2
- Option to not style the input element HOT 8
- Make `el` and `parent` options accept `Node` HOT 12
- colorArea doesn't handle right mouse button HOT 2
- Feature Request: Add Eyedropper HOT 2
- Missing info in docs about setting up thumbnails HOT 4
- Not showing in absolute positioned div HOT 2
- Alpha channel loses information HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coloris.