Skip to content

InputControl misses to set a default color for the placeholder text #69331

@afercia

Description

@afercia

Description

Discovered while working on #60275

Not sure what the plans are for the InputControl and TextareaControl components, especially regarding the CSS-in-JS part. I seem to recall there was an ongoing discussion about not using CSS-in-JS for the future so this may need to wait for a decision.

Anyways:

TextareaControl does set a default color for the placeholder text:

// Use opacity to work in various editor styles.
&::-webkit-input-placeholder {
color: ${ COLORS.ui.darkGrayPlaceholder };
}
&::-moz-placeholder {
opacity: 1; // Necessary because Firefox reduces this from 1.
color: ${ COLORS.ui.darkGrayPlaceholder };
}
&:-ms-input-placeholder {
color: ${ COLORS.ui.darkGrayPlaceholder };
}

InputControl doesn't, so it uses the browser default:

https://github.com/WordPress/gutenberg/blob/7a4b5aa5d8a63d97b084e1339e6ce544dfc944bb/packages/components/src/input-control/styles/input-control-styles.tsx

It's important to remind that the placeholder text should have a sufficient color contrast. That's the reason why Core and the Editor provide CSS to set the color by targeting the prefixed CSS selectors for -webkit, -moz, and -ms.

I would say the two components should behave consistently. They either should provide a default color or should not and delegate the styling to the consumers.

Note: according to #69311 the opacity is no longer needed for Firefox.

Cc @WordPress/gutenberg-components

Step-by-step reproduction instructions

Screenshots, screen recording, code snippet

No response

Environment info

No response

Please confirm that you have searched existing issues in the repo.

  • Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

  • Yes

Please confirm which theme type you used for testing.

  • Block
  • Classic
  • Hybrid (e.g. classic with theme.json)
  • Not sure

Metadata

Metadata

Labels

[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).[Package] Components/packages/components[Status] In ProgressTracking issues with work in progress[Type] BugAn existing feature does not function as intended

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions