Skip to content

Commit e053b64

Browse files
committed
fix color picker selecting wrong line
1 parent dbd360d commit e053b64

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

client/modules/IDE/components/Editor/stateUtils.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,23 @@ function getFileEmmetConfig(fileName) {
258258
}
259259
}
260260

261+
function getColorPickerAtSelection(view) {
262+
const { head } = view.state.selection.main;
263+
const { node } = view.domAtPos(head);
264+
265+
const startEl =
266+
node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement;
267+
268+
const lineEl = startEl?.closest('.cm-line');
269+
270+
return (
271+
lineEl?.querySelector('input[type="color"]:not(:disabled)') ||
272+
view.contentDOM.querySelector('input[type="color"]:not(:disabled)')
273+
);
274+
}
275+
261276
function openColorPickerWithKeyboard(view) {
262-
const picker = view.contentDOM.querySelector('input[type="color"]');
277+
const picker = getColorPickerAtSelection(view);
263278

264279
if (!picker || picker.disabled) {
265280
return false;

0 commit comments

Comments
 (0)