Skip to content

Commit fa9589e

Browse files
committed
Update ThemedColorInput.tsx
1 parent 9badf25 commit fa9589e

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

packages/project-editor/ui-components/PropertyGrid/ThemedColorInput.tsx

+27-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { getThemedColor } from "project-editor/features/style/theme";
1212

1313
import { ProjectContext } from "project-editor/project/context";
1414
import { settingsController } from "home/settings";
15-
import { action, observable, makeObservable } from "mobx";
15+
import { action, observable, makeObservable, runInAction } from "mobx";
1616
import { closest } from "eez-studio-shared/dom";
1717
import tinycolor from "tinycolor2";
1818

@@ -35,6 +35,20 @@ export const ThemedColorInput = observer(
3535
dropDownLeft = 0;
3636
dropDownTop = 0;
3737

38+
colorHSV: any;
39+
40+
constructor(props: any) {
41+
super(props);
42+
43+
makeObservable(this, {
44+
dropDownOpen: observable,
45+
dropDownLeft: observable,
46+
dropDownTop: observable,
47+
setDropDownOpen: action,
48+
colorHSV: observable
49+
});
50+
}
51+
3852
onDragOver = (event: React.DragEvent) => {
3953
event.preventDefault();
4054
event.stopPropagation();
@@ -71,17 +85,6 @@ export const ThemedColorInput = observer(
7185
this.props.onChange(color);
7286
};
7387

74-
constructor(props: any) {
75-
super(props);
76-
77-
makeObservable(this, {
78-
dropDownOpen: observable,
79-
dropDownLeft: observable,
80-
dropDownTop: observable,
81-
setDropDownOpen: action
82-
});
83-
}
84-
8588
setDropDownOpen(open: boolean) {
8689
if (this.dropDownOpen === false) {
8790
document.removeEventListener(
@@ -186,9 +189,19 @@ export const ThemedColorInput = observer(
186189
}}
187190
>
188191
<Chrome
189-
color={color}
192+
color={
193+
this.dropDownOpen && this.colorHSV
194+
? this.colorHSV
195+
: color
196+
}
190197
showAlpha={false}
191-
onChange={color => this.onChangeColor(color.hex, false)}
198+
onChange={color => {
199+
runInAction(() => {
200+
this.colorHSV = color.hsv;
201+
});
202+
203+
this.onChangeColor(color.hex, false);
204+
}}
192205
/>
193206
</div>,
194207
document.body

0 commit comments

Comments
 (0)