fix(import): apply dark color scheme to column mapping select
This commit is contained in:
1 parent
312673cadf
commit
c246a2cbea
6 files changed
+59
-9
No files matched your search
@@ -1559,10 +1559,10 @@ watch(rawProgressPercent, (percent) => {
|
||||
|
||||
<div v-if="supportsImportConflictPolicy" class="space-y-1.5 rounded-md border p-3">
|
||||
<Label for="table-import-conflict-policy" class="text-xs">{{ t("tableImport.conflictPolicy") }}</Label>
|
||||
<select id="table-import-conflict-policy" v-model="conflictPolicy" data-testid="table-import-conflict-policy" class="flex h-8 w-full rounded-md border border-input bg-background px-2 text-xs">
|
||||
<option value="error">{{ t("tableImport.conflictError") }}</option>
|
||||
<option value="skip">{{ t("tableImport.skipDuplicateRows") }}</option>
|
||||
<option v-if="targetMode === 'existing'" value="updateExisting" :disabled="!canUpdateExistingRows">
|
||||
<select id="table-import-conflict-policy" v-model="conflictPolicy" data-testid="table-import-conflict-policy" class="flex h-8 w-full rounded-md border border-input bg-background text-foreground px-2 text-xs [color-scheme:light] dark:[color-scheme:dark]">
|
||||
<option value="error" class="bg-popover text-popover-foreground">{{ t("tableImport.conflictError") }}</option>
|
||||
<option value="skip" class="bg-popover text-popover-foreground">{{ t("tableImport.skipDuplicateRows") }}</option>
|
||||
<option v-if="targetMode === 'existing'" value="updateExisting" :disabled="!canUpdateExistingRows" class="bg-popover text-popover-foreground">
|
||||
{{ t("tableImport.updateExistingRows") }}
|
||||
</option>
|
||||
</select>
|
||||
@@ -1622,11 +1622,11 @@ watch(rawProgressPercent, (percent) => {
|
||||
<select
|
||||
v-else
|
||||
:value="columnMapping[sourceColumn] || SKIP_VALUE"
|
||||
class="h-7 w-full min-w-0 rounded-md border bg-background px-2 text-xs font-mono shadow-none hover:bg-muted/30 focus-visible:ring-1 focus-visible:ring-ring/25"
|
||||
class="h-7 w-full min-w-0 rounded-md border border-input bg-background text-foreground px-2 text-xs font-mono shadow-none hover:bg-muted/30 focus-visible:ring-1 focus-visible:ring-ring/25 [color-scheme:light] dark:[color-scheme:dark]"
|
||||
@change="(e) => updateMapping(sourceColumn, (e.target as HTMLSelectElement).value)"
|
||||
>
|
||||
<option :value="SKIP_VALUE">{{ t("tableImport.skipColumn") }}</option>
|
||||
<option v-for="column in targetColumns" :key="column.name" :value="column.name">
|
||||
<option :value="SKIP_VALUE" class="bg-popover text-popover-foreground">{{ t("tableImport.skipColumn") }}</option>
|
||||
<option v-for="column in targetColumns" :key="column.name" :value="column.name" class="bg-popover text-popover-foreground">
|
||||
{{ column.name }}
|
||||
</option>
|
||||
</select>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
// Fixes #10142: In dark mode, native select dropdown menus in TableImportDialog
|
||||
// (such as column mapping and conflict policy) rendered with a bright white
|
||||
// popup background and light-colored text in Chromium/WebView2 because native
|
||||
// select/option elements did not specify color-scheme or popover colors.
|
||||
const tableImportDialogSource = readFileSync(new URL("../TableImportDialog.vue", import.meta.url), "utf8");
|
||||
const tokensCssSource = readFileSync(new URL("../../../styles/tokens.css", import.meta.url), "utf8");
|
||||
const globalsCssSource = readFileSync(new URL("../../../styles/globals.css", import.meta.url), "utf8");
|
||||
|
||||
describe("TableImportDialog theme and select color consistency (#10142)", () => {
|
||||
it("declares color-scheme: light in :root and color-scheme: dark in .dark within tokens.css", () => {
|
||||
expect(tokensCssSource).toMatch(/:root\s*\{[^}]*color-scheme:\s*light;/);
|
||||
expect(tokensCssSource).toMatch(/\.dark\s*\{[^}]*color-scheme:\s*dark;/);
|
||||
});
|
||||
|
||||
it("declares select color-scheme and option background in globals.css", () => {
|
||||
expect(globalsCssSource).toMatch(/select\s*\{[^}]*color-scheme:\s*light;/);
|
||||
expect(globalsCssSource).toMatch(/\.dark select[^}]*color-scheme:\s*dark;/);
|
||||
expect(globalsCssSource).toMatch(/select option\s*\{[^}]*background-color:\s*var\(--popover\);[^}]*color:\s*var\(--popover-foreground\);/);
|
||||
});
|
||||
|
||||
it("applies color-scheme and text-foreground to native select controls in TableImportDialog.vue", () => {
|
||||
expect(tableImportDialogSource).toContain('id="table-import-conflict-policy"');
|
||||
expect(tableImportDialogSource).toMatch(/id="table-import-conflict-policy"[^>]*\[color-scheme:light\] dark:\[color-scheme:dark\]/);
|
||||
expect(tableImportDialogSource).toMatch(/id="table-import-conflict-policy"[^>]*text-foreground/);
|
||||
|
||||
expect(tableImportDialogSource).toMatch(/class="[^"]*h-7 w-full min-w-0 rounded-md[^"]*\[color-scheme:light\] dark:\[color-scheme:dark\]/);
|
||||
expect(tableImportDialogSource).toMatch(/class="[^"]*h-7 w-full min-w-0 rounded-md[^"]*text-foreground/);
|
||||
});
|
||||
|
||||
it("applies bg-popover and text-popover-foreground to option elements in TableImportDialog.vue", () => {
|
||||
expect(tableImportDialogSource).toMatch(/<option[^>]*class="[^"]*bg-popover text-popover-foreground[^"]*"[^>]*>\s*\{\{ t\("tableImport\.skipColumn"\) \}\}\s*<\/option>/);
|
||||
expect(tableImportDialogSource).toMatch(/<option[^>]*class="[^"]*bg-popover text-popover-foreground[^"]*"[^>]*>\s*\{\{\s*column\.name\s*\}\}\s*<\/option>/);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user