Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ export function Unstyled() {
</div>
);
}

export function FullWidth() {
return (
<div style={{ padding: 40 }}>
<ColorInput label="Full width color picker" fullWidth popoverProps={{ opened: true }} />
</div>
);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { render } from '@testing-library/react';
import { inputDefaultProps, inputStylesApiSelectors, tests } from '@mantine-tests/core';
import { MantineProvider } from '../../core';
import { __InputStylesNames } from '../Input';
import { ColorInput, ColorInputProps } from './ColorInput';

Expand Down Expand Up @@ -34,4 +36,15 @@ describe('@mantine/core/ColorInput', () => {
props: defaultProps,
componentName: 'ColorInput',
});

it('passes fullWidth prop to ColorPicker', () => {
const { container } = render(
<MantineProvider>
<ColorInput popoverProps={{ opened: true, withinPortal: false }} fullWidth />
</MantineProvider>
);
expect(
container.querySelector('.mantine-ColorInput-dropdown [data-full-width]')
).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const ColorInput = factory<ColorInputFactory>((_props) => {
leftSection,
rightSection,
swatchesPerRow,
fullWidth,
...others
} = useInputProps('ColorInput', defaultProps, _props);

Expand Down Expand Up @@ -237,6 +238,7 @@ export const ColorInput = factory<ColorInputFactory>((_props) => {
position="bottom-start"
offset={5}
opened={dropdownOpened}
width={fullWidth ? 'target' : undefined}
{...popoverProps}
classNames={resolvedClassNames}
styles={resolvedStyles}
Expand Down Expand Up @@ -307,6 +309,7 @@ export const ColorInput = factory<ColorInputFactory>((_props) => {
classNames={resolvedClassNames}
onColorSwatchClick={() => closeOnColorSwatchClick && setDropdownOpened(false)}
attributes={wrapperProps.attributes}
fullWidth={fullWidth}
/>
</Popover.Dropdown>
</Popover>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export interface __ColorPickerProps {

/** Component size @default 'md' */
size?: MantineSize | (string & {});

/** If set, the component takes 100% width of its container @default false */
fullWidth?: boolean;
}

export interface ColorPickerProps
Expand All @@ -87,9 +90,6 @@ export interface ColorPickerProps
ElementProps<'div', 'onChange' | 'value' | 'defaultValue'> {
__staticSelector?: string;

/** If set, the component takes 100% width of its container @default false */
fullWidth?: boolean;

/** If set, interactive elements (sliders thumbs and swatches) are focusable with keyboard @default true */
focusable?: boolean;

Expand Down