Skip to content

Scope the global button:not(.clickable-icon) color override to .tldraw-view-root - #210

Open
mnaoumov wants to merge 1 commit into
tldraw:mainfrom
mnaoumov:fix/scope-button-color-override
Open

Scope the global button:not(.clickable-icon) color override to .tldraw-view-root#210
mnaoumov wants to merge 1 commit into
tldraw:mainfrom
mnaoumov:fix/scope-button-color-override

Conversation

@mnaoumov

Copy link
Copy Markdown

Fixes #203.

src/styles.css ships an unscoped global rule:

button:not(.clickable-icon) {
  color: currentColor;
}

Because it isn't scoped to a tldraw container, it applies to every <button> in Obsidian, overriding Obsidian's default button:not(.clickable-icon){color:var(--text-color)} app-wide. currentColor then resolves to whatever text color the surrounding context inherits, so buttons outside tldraw lose contrast wherever that differs from their background — e.g. the Settings "Check for Updates" button in #203, and action buttons inside a Notice (white-on-white).

This scopes the rule to .tldraw-view-root, matching the convention already used right below it for the .tldraw-view-root .tlui-button override. Specificity becomes (0,2,1), so it still wins over Obsidian's (0,1,1) inside the tldraw view, while no longer leaking to the rest of the app.

Note: this assumes all tldraw buttons live under .tldraw-view-root (true for the in-view UI; the existing .tldraw-view-root .tlui-button override relies on the same assumption). If any tldraw UI is portaled outside that root, .tl-container would be the alternative scope.

The global rule applied `color: currentColor` to every button in Obsidian, not
just tldraw's, overriding Obsidian's default button text color app-wide and
breaking contrast outside tldraw (Settings buttons, Notice action buttons).
Scope it to the tldraw view, matching the convention already used for the
.tldraw-view-root .tlui-button override below it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
mnaoumov added a commit to mnaoumov/obsidian-dev-utils that referenced this pull request Jun 26, 2026
The tldraw Obsidian plugin ships an unscoped global
`button:not(.clickable-icon) { color: currentColor }` rule that overrides
Obsidian's own `button:not(.clickable-icon) { color: var(--text-color) }`
app-wide. Obsidian sets `--text-color` contextually per button variant, so
tldraw's `currentColor` discards that and breaks button contrast in any consuming
plugin's UI -- e.g. white-on-white action buttons inside a Notice. Re-assert
Obsidian's own value with a `body`-prefixed selector (specificity 0,1,2) so it
wins over tldraw's (0,1,1) while staying correct for every variant. Defensive
workaround until the upstream fix ships (tldraw/obsidian-plugin#210).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

Plugin Changes Text Color on Buttons Outside of TLDraw

1 participant