Color picker displays wrong position
Question

Answers (3)
Hi there, I solved this using the following configuration:
grapesjs.init({ colorPicker: { appendTo: 'parent', offset: { top: 26, left: -166, }, }, })
Maybe you need to adjust the top and left positions for you, because I changed some sizes. But works perfect here.
I had exactly the same problem and thanks to your pointer to ColorPicker.js I was able to fix.
Like artf say, the calculation of position is wrong, when editor is shown with a popup, like bootstrap modal. So I replaced the correction lines here like this:
offset.left -= Math.min(
offset.left,
offset.left + dpWidth > viewWidth && viewWidth > dpWidth
? Math.abs(offset.left + dpWidth - viewWidth)
: 0
);
offset.top -= Math.min(
offset.top,
offset.top + dpHeight > viewHeight && viewHeight > dpHeight
? Math.abs(dpHeight + inputHeight - extraY)
: extraY
);
to a simple
offset.left += input.outerWidth();
offset.left -= input.closest(".gjs-editor").offset().left;
offset.left -= dpWidth;
offset.top += inputHeight;
offset.top -= input.closest(".gjs-editor").offset().top;
This works perfect for me, because I took input offset and subtract the offset of popup and datepicker. to more.
I only don't create a Merge request, because I think it isn't the best way to handle this. Also the top position must better recognize browser borders. I will try to optimize the change and create some full page test cases over weekend, because I love this editor. There is also probably a default way to get container element, which I oversee during code research.
Are you able to provide a live example of the issue? (jsfiddle, codepen, etc..)
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1434
Toolbar Hide text element
@artf Please check you demo page text is hiding under the toolbar. how can we update the toolbar position?
Issue #1711
Error in prompt position after moving canvas
1、移动画布 2、点击layerManager(如果不点击layerManager 不会出错) 3、画布里的提示框位置出错 1、 moving canvas 2、 click layerManager (If you don't click layerManager, it w...
Issue #2044
Npm start to develop on local server didn't work
Did the procedure to start the local server using dev branch as described on README, it worked on the console, but fails on chrome and the...
Issue #678
Help Wanted
Hello, 2 queries : 1) How to Add a LOGO as in Demo webpage. 2) How to move the block manager, Style Manager from Right Side to Left Side. T...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.