Skip to content

Conversation

@manuhabitela
Copy link
Collaborator

@manuhabitela manuhabitela commented Nov 26, 2025

Context

This is a follow-up to #1529, where we made sure that choice tokens with custom bg color but no custom fg color would not become unreadable when switching from light to dark themes.

The tokens that were rendered when editing a text cell did not benefit from the previous fix. So while the tokens stayed readable when looking at them, they could go back to being unreadable when editing them after double clicking a cell (with automatic light text in dark theme, on a light custom bg, for example).

Proposed solution

Make sure the choices text box also applies the "readable colors combo" calculation.

Related issues

#1155, see this comment: #1155 (comment)

Has this been tested?

  • 👍 yes, I added tests to the test suite
  • 💭 no, because this PR is a draft and still needs work
  • 🙅 no, because this is not relevant here
  • 🙋 no, because I need help

Screenshots / Screencasts

Before:

choices-editor-before.mp4

After:

choices-editor-after.mp4

Sorry it took so long @S7venLights 😬

@manuhabitela manuhabitela added the bug Something isn't working label Nov 26, 2025
@manuhabitela manuhabitela moved this to Needs Internal Feedback in French administration Board Nov 26, 2025
Copy link
Collaborator

@hexaltation hexaltation left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
Thanks Mr. @manuhabitela

@fflorent fflorent moved this from Needs Internal Feedback to Needs feedback in French administration Board Nov 26, 2025
Copy link
Member

@dsagal dsagal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This works, but I think we can reuse code better. Would you mind trying to get rid of getRenderFillColor and getRenderTextColor entirely, and replacing their only usage (in ChoiceListEditor.ts) with a call to choiceToken() instead? (Since the code for renderToken in ChoiceListEditor.ts seems to duplicate the code in choiceToken, which already deals correctly with colors.) It seems possible, perhaps with a little tweaking here and there, but if it's not looking like an improvement or if you get bogged down, let me know.

This is a follow-up to
gristlabs#1529,
where we made sure that choice tokens with custom bg color but no custom
fg color would not become unreadable when switching from light to dark
themes.

The tokens that were rendered when editing a text cell did not benefit
from this fix. So while the tokens stayed readable when looking at them,
they could go back to being unreadable when editing them after
double-clicking the cell (with automatic light text in dark theme, on a
light custom bg, for example).

This fixes that use-case.
@manuhabitela manuhabitela force-pushed the fix-choices-editor-colors branch from 1b8a9e4 to a8b089c Compare December 5, 2025 12:50
@manuhabitela
Copy link
Collaborator Author

Thanks Dmitry. I had a try at it in the last commit. What do you think?

Copy link
Member

@dsagal dsagal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, this is what I was hoping for! I just have a very tiny nitpick.

export function choiceTokenDomArgs(
label: DomElementArg,
options: IChoiceTokenOptions,
...args: DomElementArg[]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to omit this ...args argument -- the caller can simply add extra args to the DOM after the result of this call, e.g.

cssChoiceToken(choiceTokenDomArgs(label, options), ...args);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, woops, thanks.

@manuhabitela manuhabitela force-pushed the fix-choices-editor-colors branch from a8b089c to 426dc3f Compare December 9, 2025 13:47
Copy link
Member

@dsagal dsagal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thanks! It's my favorite kind of change: fixing bugs by reducing the amount of code.

@dsagal dsagal merged commit 878fc60 into gristlabs:main Dec 9, 2025
14 of 15 checks passed
@github-project-automation github-project-automation bot moved this from Needs feedback to Done in French administration Board Dec 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants