diff --git a/biome.json b/biome.json index a69eba8c07..e01856c438 100644 --- a/biome.json +++ b/biome.json @@ -57,7 +57,11 @@ "noAccumulatingSpread": "off" }, "a11y": { - "useKeyWithClickEvents": "off" + "noAriaHiddenOnFocusable": "off", + "noLabelWithoutControl": "off", + "useFocusableInteractive": "off", + "useKeyWithClickEvents": "off", + "useSemanticElements": "off" } } }, diff --git a/components/color-picker/__tests__/index.test.tsx b/components/color-picker/__tests__/index.test.tsx index 933a929679..a934509722 100644 --- a/components/color-picker/__tests__/index.test.tsx +++ b/components/color-picker/__tests__/index.test.tsx @@ -936,4 +936,16 @@ describe('ColorPicker', () => { }); }); }); + + it('input precision', async () => { + const onChange = jest.fn(); + const { container } = render(); + + fireEvent.change(container.querySelector('.ant-color-picker-hex-input input')!, { + target: { value: '2ddcb4' }, + }); + + const onChangeColor = onChange.mock.calls[0][0]; + expect(onChangeColor.toHexString()).toBe('#2ddcb4'); + }); }); diff --git a/components/color-picker/util.ts b/components/color-picker/util.ts index d29dc72748..f2107af95b 100644 --- a/components/color-picker/util.ts +++ b/components/color-picker/util.ts @@ -19,9 +19,18 @@ export const getColorAlpha = (color: AggregationColor) => getRoundNumber(color.t /** Return the color whose `alpha` is 1 */ export const genAlphaColor = (color: AggregationColor, alpha?: number) => { - const hsba = color.toHsb(); - hsba.a = alpha || 1; - return generateColor(hsba); + const rgba = color.toRgb(); + + // Color from hsb input may get `rgb` is (0/0/0) when `hsb.b` is 0 + // So if rgb is empty, we should get from hsb + if (!rgba.r && !rgba.g && !rgba.b) { + const hsba = color.toHsb(); + hsba.a = alpha || 1; + return generateColor(hsba); + } + + rgba.a = alpha || 1; + return generateColor(rgba); }; /**