Skip to content

Fix inline toolbar background for dark mode#102

Merged
JohnMcLear merged 2 commits into
masterfrom
copilot/fix-background-color-dark-mode
May 12, 2026
Merged

Fix inline toolbar background for dark mode#102
JohnMcLear merged 2 commits into
masterfrom
copilot/fix-background-color-dark-mode

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 12, 2026

The inline toolbar background was hardcoded to #ffffff in postToolbarInit, so it stayed white regardless of the user's colour scheme.

Changes

  • static/js/index.js: Replace the JS .css('background-color', '#ffffff') call with a <style> injection into the ace_outer iframe document. Uses prefers-color-scheme: dark so the browser handles switching automatically — no JS re-evaluation needed. Colours mirror Etherpad's own toolbar (#f4f4f4 light / #1a1a1a dark).
const $style = $('<style>').text(
    '#inline_toolbar { background-color: #f4f4f4; }\n' +
    '@media (prefers-color-scheme: dark) {\n' +
    '  #inline_toolbar { background-color: #1a1a1a; }\n' +
    '}',
);
$(outerDoc.head).append($style);
  • static/tests/backend/specs/background_fix.js: Add regression assertions — prefers-color-scheme: dark rule must be present in source, and hardcoded white via .css() must not be used.

Replace the hardcoded `$('#inline_toolbar').css('background-color',
'#ffffff')` call with a CSS injection into the ace_outer iframe document.
The injected <style> uses a prefers-color-scheme: dark media query so the
toolbar automatically switches between the Etherpad light-mode toolbar
colour (#f4f4f4) and a dark-mode colour (#1a1a1a) without any JS
re-evaluation.

Also add a regression test that asserts:
  - a prefers-color-scheme: dark rule is present in the source
  - the hardcoded white background via .css() is not used

Agent-Logs-Url: https://github.com/ether/ep_inline_toolbar/sessions/1465865b-03bd-4d78-a983-28e9cb52797d

Co-authored-by: JohnMcLear <220864+JohnMcLear@users.noreply.github.com>
@JohnMcLear JohnMcLear marked this pull request as ready for review May 12, 2026 11:18
@qodo-code-review
Copy link
Copy Markdown

ⓘ You've reached your Qodo monthly free-tier limit. Reviews pause until next month — upgrade your plan to continue now, or link your paid account if you already have one.

Copilot AI changed the title [WIP] Fix background color for dark mode Fix inline toolbar background for dark mode May 12, 2026
@JohnMcLear JohnMcLear merged commit 711a5d2 into master May 12, 2026
1 of 2 checks passed
@JohnMcLear JohnMcLear deleted the copilot/fix-background-color-dark-mode branch May 12, 2026 11:18
Copilot stopped work on behalf of JohnMcLear due to an error May 12, 2026 11:18
Copilot AI requested a review from JohnMcLear May 12, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Background color does not change for dark mode

2 participants