From 6d66cdacd8bbcb697ff007ffd6867187aa660738 Mon Sep 17 00:00:00 2001 From: Glary-Bot Date: Wed, 20 May 2026 22:54:23 +0000 Subject: [PATCH] refactor: drop primevue/colorpicker from FormColorPicker and ColorCustomizationSelector (FE-804) --- .../common/ColorCustomizationSelector.test.ts | 37 ++++++++++--------- .../common/ColorCustomizationSelector.vue | 10 +++-- src/components/common/CustomizationDialog.vue | 21 +---------- src/components/common/FormColorPicker.vue | 22 +++++++++-- 4 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/components/common/ColorCustomizationSelector.test.ts b/src/components/common/ColorCustomizationSelector.test.ts index 165c03667c..bd036b9dbc 100644 --- a/src/components/common/ColorCustomizationSelector.test.ts +++ b/src/components/common/ColorCustomizationSelector.test.ts @@ -1,10 +1,10 @@ import { render } from '@testing-library/vue' import userEvent from '@testing-library/user-event' -import ColorPicker from 'primevue/colorpicker' import PrimeVue from 'primevue/config' import SelectButton from 'primevue/selectbutton' import { beforeEach, describe, expect, it, vi } from 'vitest' import { createApp, nextTick } from 'vue' +import { createI18n } from 'vue-i18n' import ColorCustomizationSelector from './ColorCustomizationSelector.vue' @@ -14,6 +14,12 @@ describe('ColorCustomizationSelector', () => { { name: 'Green', value: '#28a745' } ] + const i18n = createI18n({ + legacy: false, + locale: 'en', + messages: { en: { color: { hex: 'Hex', rgba: 'RGBA' } } } + }) + beforeEach(() => { const app = createApp({}) app.use(PrimeVue) @@ -27,8 +33,8 @@ describe('ColorCustomizationSelector', () => { const result = render(ColorCustomizationSelector, { global: { - plugins: [PrimeVue], - components: { SelectButton, ColorPicker } + plugins: [PrimeVue, i18n], + components: { SelectButton } }, props: { modelValue: null, @@ -68,24 +74,21 @@ describe('ColorCustomizationSelector', () => { const buttons = getToggleButtons(container) const customButton = buttons[buttons.length - 1] expect(customButton).toHaveAttribute('aria-pressed', 'true') - - // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access -- PrimeVue ColorPicker uses readonly input preview with no ARIA role - const colorPreview = container.querySelector( - '.p-colorpicker-preview' - ) as HTMLInputElement | null - expect(colorPreview).not.toBeNull() }) it('shows color picker when custom option is selected', async () => { - const { container, user } = renderComponent() + const { container, user } = renderComponent({ modelValue: '#0d6efd' }) + await nextTick() - const buttons = getToggleButtons(container) - await user.click(buttons[buttons.length - 1]) + // eslint-disable-next-line testing-library/no-node-access, testing-library/no-container -- count buttons to detect the ColorPicker popover trigger appearing + const initialButtonCount = container.querySelectorAll('button').length + const toggleButtons = getToggleButtons(container) + await user.click(toggleButtons[toggleButtons.length - 1]) + await nextTick() - expect( - // eslint-disable-next-line testing-library/no-container, testing-library/no-node-access -- PrimeVue ColorPicker internal DOM - container.querySelector('[data-pc-name="colorpicker"]') - ).not.toBeNull() + // eslint-disable-next-line testing-library/no-node-access, testing-library/no-container -- count buttons to detect the ColorPicker popover trigger appearing + const afterButtonCount = container.querySelectorAll('button').length + expect(afterButtonCount).toBe(initialButtonCount + 1) }) it('emits update when predefined color is selected', async () => { @@ -117,7 +120,7 @@ describe('ColorCustomizationSelector', () => { onUpdate.mockClear() await user.click(buttons[buttons.length - 1]) // Switch to custom - // When switching to custom, the custom color value inherits from Blue ('0d6efd') + // When switching to custom, the custom color value inherits from Blue // and the watcher on customColorValue emits the update expect(onUpdate).toHaveBeenCalledWith('#0d6efd') }) diff --git a/src/components/common/ColorCustomizationSelector.vue b/src/components/common/ColorCustomizationSelector.vue index b25d265ea0..fe7ec99ed1 100644 --- a/src/components/common/ColorCustomizationSelector.vue +++ b/src/components/common/ColorCustomizationSelector.vue @@ -25,15 +25,17 @@ diff --git a/src/components/common/CustomizationDialog.vue b/src/components/common/CustomizationDialog.vue index 12eac61a1d..36e0a0fbae 100644 --- a/src/components/common/CustomizationDialog.vue +++ b/src/components/common/CustomizationDialog.vue @@ -2,11 +2,7 @@ - + {{ $t('g.customizeFolder') }} @@ -92,21 +88,6 @@ const emit = defineEmits<{ const titleId = useId() -// PrimeVue ColorPicker overlay teleports to body. Reka treats clicks on it as -// outside and would dismiss the dialog mid-color-pick. Treat any PrimeVue -// overlay click as inside. -const PRIMEVUE_OVERLAY_SELECTORS = - '.p-colorpicker-panel, .p-overlay, .p-overlay-mask' - -function onPointerDownOutside( - event: CustomEvent<{ originalEvent: PointerEvent }> -) { - const target = event.detail.originalEvent.target - if (target instanceof Element && target.closest(PRIMEVUE_OVERLAY_SELECTORS)) { - event.preventDefault() - } -} - const nodeBookmarkStore = useNodeBookmarkStore() const iconOptions = [ diff --git a/src/components/common/FormColorPicker.vue b/src/components/common/FormColorPicker.vue index 7e42147516..d01533749d 100644 --- a/src/components/common/FormColorPicker.vue +++ b/src/components/common/FormColorPicker.vue @@ -1,13 +1,15 @@