Skip to content

Commit

Permalink
fixed #230, color input not getting removed from DOM
Browse files Browse the repository at this point in the history
  • Loading branch information
mienaiyami committed Aug 9, 2023
1 parent 9aa7d47 commit 9330569
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Components/Element/InputColorReal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const VALID_SLIDER = {
type ValidSlider = keyof typeof VALID_SLIDER;

const InputColorReal = () => {
const { colorSelectData } = useContext(AppContext);
const { colorSelectData, setColorSelectData } = useContext(AppContext);
const [pos, setPos] = useState({ x: 0, y: 0 });
const [formatSelected, setFormatSelected] = useState(0);
const [color, setColor] = useState(window.color.new());
Expand Down Expand Up @@ -148,10 +148,11 @@ const InputColorReal = () => {
id="realColorInput"
tabIndex={-1}
onBlur={(e) => {
if (e.target === e.currentTarget || e.currentTarget.contains(e.target)) return;
if (e.currentTarget.contains(e.relatedTarget)) return;
// if(e.target)
colorSelectData.focusBackElem && colorSelectData.focusBackElem.focus();
colorSelectData.onBlur && colorSelectData.onBlur(e);
setColorSelectData(null);
}}
// onClick={onClick}
// onContextMenu={onClick}
Expand All @@ -173,7 +174,7 @@ const InputColorReal = () => {
"--color-noAlpha": window.color.new(color).alpha(1).hsl().string(),
}}
onKeyDown={(e) => {
if (!e.ctrlKey) {
if (!e.ctrlKey || e.key !== "Escape") {
e.stopPropagation();
e.preventDefault();
}
Expand Down

0 comments on commit 9330569

Please sign in to comment.