Skip to content

fix: set border- and label-color for in/valid state of textarea, custom select and input #4258

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

michaelmkraus
Copy link
Contributor

@michaelmkraus michaelmkraus commented May 23, 2025

Proposed changes

  • set border of textarea to corresponding color when in/valid state is set
  • set floating label color of textarea, input and custom select to corresponding color when in/valid state is set

closes #4209

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (fix on existing components or architectural decisions)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Copy link
Contributor

@michaelmkraus michaelmkraus moved this to 👀 In review in UX Engineering Team Backlog May 23, 2025
@michaelmkraus michaelmkraus marked this pull request as ready for review May 23, 2025 09:25
@michaelmkraus michaelmkraus changed the title feat: set border- and label-color for in/valid state of textarea, custom select and input fix: set border- and label-color for in/valid state of textarea, custom select and input May 23, 2025
@mfranzke mfranzke enabled auto-merge (squash) May 27, 2025 08:12
Comment on lines 390 to 399

&:is(textarea) {
@each $state, $variant in (valid: successful, invalid: critical) {
&[data-custom-validity="#{$state}"] {
border: var(--db-border-width-3xs)
solid
var(--db-#{$variant}-on-bg-basic-emphasis-70-default);
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
&:is(textarea) {
@each $state, $variant in (valid: successful, invalid: critical) {
&[data-custom-validity="#{$state}"] {
border: var(--db-border-width-3xs)
solid
var(--db-#{$variant}-on-bg-basic-emphasis-70-default);
}
}
}

We don't need this here replace https://github.com/db-ux-design-system/core-web/pull/4258/files#diff-fc8ed644a470e8653bcb58e284747ce63f7ab258a112d921ab5605159aa41a8cR204-R228 with:

` & {
@if ($selector == textarea) {
--db-textarea-read-only: var(
--db-#{$variant}-bg-basic-level-1-default
);
}

	@extend %db-#{$variant}-variables;
}`

I don't know why there was a workaround for textarea but with this we set all adaptive colors like we should.

Comment on lines +156 to +173

@each $state, $variant in (valid: successful, invalid: critical) {
&[data-custom-validity="#{$state}"] > label,
&:has(> #{$selector}[data-custom-validity="#{$state}"]) > label {
color: var(--db-#{$variant}-on-bg-basic-emphasis-70-default);
}

@if ($selector == textarea) {
&:has(> #{$selector}[data-custom-validity="#{$state}"]) {
&::before,
&::after {
// necessary to force this override over the placeholder-content mixin's ::before rule
// to avoid the label to influence the border of the textarea
content: none !important;
}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
@each $state, $variant in (valid: successful, invalid: critical) {
&[data-custom-validity="#{$state}"] > label,
&:has(> #{$selector}[data-custom-validity="#{$state}"]) > label {
color: var(--db-#{$variant}-on-bg-basic-emphasis-70-default);
}
@if ($selector == textarea) {
&:has(> #{$selector}[data-custom-validity="#{$state}"]) {
&::before,
&::after {
// necessary to force this override over the placeholder-content mixin's ::before rule
// to avoid the label to influence the border of the textarea
content: none !important;
}
}
}
}

You cannot remove the content on ::before or ::after it is a workaround to ensure the floating label stays above the text. You see the problem, when you add a lot of text into the textarea.

Copy link
Contributor Author

@michaelmkraus michaelmkraus Jun 5, 2025

Choose a reason for hiding this comment

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

I see the problem with long texts. We could handle it like that

Suggested change
@each $state, $variant in (valid: successful, invalid: critical) {
&[data-custom-validity="#{$state}"] > label,
&:has(> #{$selector}[data-custom-validity="#{$state}"]) > label {
color: var(--db-#{$variant}-on-bg-basic-emphasis-70-default);
}
@if ($selector == textarea) {
&:has(> #{$selector}[data-custom-validity="#{$state}"]) {
&::before,
&::after {
// necessary to force this override over the placeholder-content mixin's ::before rule
// to avoid the label to influence the border of the textarea
content: none !important;
}
}
}
}
@each $state, $variant in (valid: successful, invalid: critical) {
&[data-custom-validity="#{$state}"] > label,
&:has(> #{$selector}[data-custom-validity="#{$state}"]) > label {
color: var(--db-#{$variant}-on-bg-basic-emphasis-70-default);
}
@if ($selector == textarea) {
&:has(> #{$selector}[data-custom-validity="#{$state}"]) {
&::before,
&::after {
// necessary to force this override over the placeholder-content mixin's ::before rule
// to avoid the label to influence the border of the textarea
border-color: transparent;
background-color: inherit !important;
}
}
}
}

This way, we would keep the workaround and ensure that the label does not influence the border of the textarea.

@nmerget
Copy link
Collaborator

nmerget commented Jun 3, 2025

There is another issue with the label for variant="floating" it should be colored with the invalid or valid color

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 👀 In review
Development

Successfully merging this pull request may close these issues.

valid & invalid input fields: wrong colors for border and label
3 participants