Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/components/fields/fields.component.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { memo, useCallback, useEffect, useState } from "react";
import React, { memo, useCallback, useEffect, useId, useState } from "react";

import { ColorService, type IColor } from "@/services/color";

Expand All @@ -14,6 +14,7 @@ interface IFieldsProps {
}

export const Fields = memo(({ hideInput, color, disabled, onChange, onChangeComplete }: IFieldsProps) => {
const id = useId();
const [fields, setFields] = useState({
hex: {
value: color.hex,
Expand Down Expand Up @@ -89,15 +90,15 @@ export const Fields = memo(({ hideInput, color, disabled, onChange, onChangeComp
<div className="rcp-fields-floor">
<div className="rcp-field">
<input
id="hex"
id={`${id}-hex`}
className="rcp-field-input"
readOnly={disabled}
value={fields.hex.value}
onChange={onInputChange("hex")}
onFocus={onInputFocus("hex")}
onBlur={onInputBlur("hex")}
/>
<label htmlFor="hex" className="rcp-field-label">
<label htmlFor={`${id}-hex`} className="rcp-field-label">
HEX
</label>
</div>
Expand All @@ -108,31 +109,31 @@ export const Fields = memo(({ hideInput, color, disabled, onChange, onChangeComp
{!isFieldHide(hideInput, "rgb") && (
<div className="rcp-field">
<input
id="rgb"
id={`${id}-rgb`}
className="rcp-field-input"
readOnly={disabled}
value={fields.rgb.value}
onChange={onInputChange("rgb")}
onFocus={onInputFocus("rgb")}
onBlur={onInputBlur("rgb")}
/>
<label htmlFor="rgb" className="rcp-field-label">
<label htmlFor={`${id}-rgb`} className="rcp-field-label">
RGB
</label>
</div>
)}
{!isFieldHide(hideInput, "hsv") && (
<div className="rcp-field">
<input
id="hsv"
id={`${id}-hsv`}
className="rcp-field-input"
readOnly={disabled}
value={fields.hsv.value}
onChange={onInputChange("hsv")}
onFocus={onInputFocus("hsv")}
onBlur={onInputBlur("hsv")}
/>
<label htmlFor="hsv" className="rcp-field-label">
<label htmlFor={`${id}-hsv`} className="rcp-field-label">
HSV
</label>
</div>
Expand Down