Skip to content

Components: Fix Styling for TextControland TextAreaControl in dark themes #69640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 5, 2025

Conversation

im3dabasia
Copy link
Contributor

@im3dabasia im3dabasia commented Mar 20, 2025

What?

Closes #69639

This PR introduces theming support for the TextControl and TextAreaControl components.

Why?

This enhancement is necessary because the previous fixed styling approach left components visually inaccessible in dark mode environments, creating poor contrast and readability issues that compromised user experience.

How?

The corresponding SCSS files have been updated to use theming.

Testing Instructions

  1. Run storybook locally. (npm run storybook:dev)
  2. Navigate to the TextControl component.
  3. Change the theme and confirm that there are no visibility issues.
  4. Navigate to the TextAreaControl component, and repeat step 3.

Screenshots

TextControl

Light mode

Before After
image image

Dark mode

Before After
image image

TextAreaControl

Light mode

Before After
image image

Dark mode

Before After
image Screenshot 2025-03-20 at 7 22 26 PM

@im3dabasia im3dabasia force-pushed the fix/darkmode-text-controls branch from eacf2d2 to f470385 Compare March 20, 2025 15:20
@im3dabasia im3dabasia marked this pull request as ready for review March 20, 2025 15:59
@im3dabasia im3dabasia requested a review from ajitbohra as a code owner March 20, 2025 15:59
Copy link

github-actions bot commented Mar 20, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@yogeshbhutkar yogeshbhutkar left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, @im3dabasia! I tested it across all available themes, and everything looks great ✅.

TextControl TextareaControl
text-control textarea-control

P.S. This PR is a part of the following tracker #69646

@im3dabasia
Copy link
Contributor Author

Hi @Mamaduka and @t-hamano ,

When you have a moment please review my PR.

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. Needs Design Feedback Needs general design feedback. [Package] Components /packages/components labels Mar 24, 2025
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I don't think using a transparent background color to be compatible with dark themes is the right approach.

For example, if there is a coloured background behind the control, it's difficult to see the text. I think this isn't what we want:

trunk This PR
before after

I'm not sure what is the best approach to make components fully compatible dark themes for now, but it would be good to discuss in #69639 #69646 before moving this PR forward.

I think the most important thing is to ensure that the control background color and the text have sufficient contrast, no matter what color the control background is.

P.S. This issue should be related to #69639: #44116

cc @WordPress/gutenberg-components

@im3dabasia
Copy link
Contributor Author

I think the most important thing is to ensure that the control background color and the text have sufficient contrast, no matter what color the control background is.

P.S. This issue should be related to #69639: #44116

Thanks for the review @t-hamano !

The related issue #69639 is closed and marked as completed. I believe this is the updated issue tracker: #69646

@im3dabasia
Copy link
Contributor Author

I am attaching the screenshots of the changes below. Please take a look. I look forward to your feedback.

TextControl

Screenshot 2025-03-25 at 2 26 01 PM

TextareaControl

Screenshot 2025-03-25 at 2 29 13 PM

cc: @t-hamano , @ciampo , @yogeshbhutkar

@im3dabasia im3dabasia force-pushed the fix/darkmode-text-controls branch from c8fc768 to 35dcf7f Compare March 25, 2025 09:05
@im3dabasia im3dabasia force-pushed the fix/darkmode-text-controls branch from 35dcf7f to 989a0d0 Compare March 25, 2025 10:56
Comment on lines 33 to 35
&:focus {
border-color: $components-color-accent;
box-shadow: 0 0 0 0.5px $components-color-accent;
// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 5px solid transparent;
}
Copy link
Contributor

@yogeshbhutkar yogeshbhutkar Mar 26, 2025

Choose a reason for hiding this comment

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

It looks like you're overriding the focus styles applied using the input-style__focus mixin here.

As per @ciampo's review (in my PR), I'm refining the mixin to support custom accents. Once/If this PR gets merged, you can rebase and use input-style__focus with custom accents directly, as recommended here.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM — let's wait for #69638 to land, so that the input-style__focus can be re-used

@yogeshbhutkar
Copy link
Contributor

Hi @im3dabasia, the PR #69638 has just landed. If possible, could you rebase and refactor the changeset as discussed earlier? Thanks!

@im3dabasia im3dabasia force-pushed the fix/darkmode-text-controls branch from 989a0d0 to 95dd4bc Compare April 4, 2025 05:41
@im3dabasia im3dabasia force-pushed the fix/darkmode-text-controls branch from 02a9bba to 14c091a Compare April 30, 2025 11:13
@im3dabasia im3dabasia requested a review from ciampo April 30, 2025 11:15
@t-hamano
Copy link
Contributor

t-hamano commented May 1, 2025

Thanks for the update!

From what I've tested, this PR works fine. Are the visual changes as shown below?

TextControl

Before After
image image
image image
image image
  • Theme-based text and background colors
  • Fixed focus outline color in dark themes
  • Fixed focus outline color in classic (accent) theme

TextareaControl

Before After
image image
image image
  • Theme-based text and background colors
  • Fixed invisible placeholder text in dark themes

@t-hamano
Copy link
Contributor

t-hamano commented May 1, 2025

If you rebase this PR, the CI failure will be fixed. See #70034.

@im3dabasia im3dabasia force-pushed the fix/darkmode-text-controls branch from 14c091a to 93ae414 Compare May 2, 2025 10:59
Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM!

@im3dabasia im3dabasia force-pushed the fix/darkmode-text-controls branch from 93ae414 to d774b13 Compare May 5, 2025 11:30
@im3dabasia im3dabasia requested a review from t-hamano May 5, 2025 11:31
@Mamaduka Mamaduka merged commit 1f9744c into WordPress:trunk May 5, 2025
61 checks passed
@github-actions github-actions bot added this to the Gutenberg 20.9 milestone May 5, 2025
chriszarate pushed a commit to chriszarate/gutenberg that referenced this pull request Jul 1, 2025
…k themes (WordPress#69640)

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: yogeshbhutkar <yogeshbhutkar@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Design Feedback Needs general design feedback. [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text/Textarea Control lacks theming support
5 participants