Skip to content

Commit

Permalink
[@mantine/tiptap] Fix incorrect color displayed in color control in d…
Browse files Browse the repository at this point in the history
…ark color scheme (#4560)

* Update ColorPickerControl.tsx

Updated ColorPickerControl.tsx to resolve the issue "Rich Text Editor's color picker now showing black color as default in dark color scheme"

* Update ColorPickerControl.tsx

prettier issue?

* Update ColorPickerControl.tsx

I sure hope this works!

* formatting
  • Loading branch information
hellolol2016 authored Aug 7, 2023
1 parent 9b38a94 commit 173953a
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
Tooltip,
ColorPickerProps,
useComponentDefaultProps,
useMantineTheme,
} from '@mantine/core';
import { useDisclosure } from '@mantine/hooks';
import { IconCircleOff, IconColorPicker, IconX, IconPalette, IconCheck } from '@tabler/icons-react';
Expand Down Expand Up @@ -43,7 +44,11 @@ export const ColorPickerControl = forwardRef<HTMLButtonElement, ColorPickerContr
const { editor, labels, unstyled } = useRichTextEditorContext();
const [opened, { toggle, close }] = useDisclosure(false);
const [state, setState] = useState<'palette' | 'colorPicker'>('palette');
const currentColor = editor?.getAttributes('textStyle').color || '#000';
const theme = useMantineTheme();
const currentColor =
editor?.getAttributes('textStyle').color || theme.colorScheme === 'dark'
? theme.colors.dark[1]
: theme.colors.blue[1];

const handleChange = (value: string, shouldClose = true) => {
(editor.chain() as any).focus().setColor(value).run();
Expand Down Expand Up @@ -92,7 +97,7 @@ export const ColorPickerControl = forwardRef<HTMLButtonElement, ColorPickerContr
</Popover.Target>

<Popover.Dropdown
sx={(theme) => ({
sx={() => ({
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark[7] : theme.white,
})}
>
Expand Down

0 comments on commit 173953a

Please sign in to comment.