fix(textarea): update disabled and readonly to match ionic theme (#30187)

Issue number: internal

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->
- There was a misalignment between the disabled and readonly state
textarea with the desired designed UX.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

- update textarea css vars;
- add styles for disabled textarea;
- add styles for readonly textarea;

## Does this introduce a breaking change?

- [ ] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer
for more information.
-->


## Other information

<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->
[textarea
preview](https://ionic-framework-git-rou-11586-ionic1.vercel.app/src/components/textarea/test/basic?ionic:theme=ionic)

---------

Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
This commit is contained in:
João Ferreira
2025-02-13 19:19:35 +00:00
committed by GitHub
parent ae78967b3c
commit 061712318c
9 changed files with 38 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
import { configs, test } from '@utils/test/playwright'; import { configs, test } from '@utils/test/playwright';
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => { configs({ modes: ['ios', 'md', 'ionic-md'], directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
test.describe(title('textarea: states'), () => { test.describe(title('textarea: states'), () => {
test('should render readonly textarea correctly', async ({ page }) => { test('should render readonly textarea correctly', async ({ page }) => {
await page.setContent( await page.setContent(

View File

@ -6,9 +6,10 @@
// -------------------------------------------------- // --------------------------------------------------
:host { :host {
--border-color: #{globals.$ion-primitives-neutral-500};
--color: #{globals.$ion-primitives-neutral-1200}; --color: #{globals.$ion-primitives-neutral-1200};
--highlight-color-valid: #{globals.$ion-semantics-success-base}; --highlight-color-valid: #{globals.$ion-semantics-success-900};
--highlight-color-invalid: #{globals.$ion-semantics-danger-base}; --highlight-color-invalid: #{globals.$ion-semantics-danger-800};
--placeholder-color: #{globals.$ion-primitives-neutral-800}; --placeholder-color: #{globals.$ion-primitives-neutral-800};
--placeholder-opacity: 1; --placeholder-opacity: 1;
--background: #{globals.$ion-primitives-base-white}; --background: #{globals.$ion-primitives-base-white};
@ -166,3 +167,35 @@ ion-icon {
:host(.has-focus) .textarea-highlight { :host(.has-focus) .textarea-highlight {
transform: scale(1); transform: scale(1);
} }
// Textarea Hover
// ----------------------------------------------------------------
@media (any-hover: hover) {
:host(:hover) {
--border-color: #{globals.$ion-primitives-neutral-600};
}
}
// Textarea - Disabled
// ----------------------------------------------------------------
:host(.textarea-disabled) {
--color: #{globals.$ion-primitives-neutral-500};
--background: #{globals.$ion-primitives-neutral-100};
--border-color: #{globals.$ion-primitives-neutral-300};
--placeholder-color: #{globals.$ion-primitives-neutral-500};
}
:host(.textarea-disabled:not(.ion-valid)) .textarea-bottom .helper-text,
:host(.textarea-disabled) .textarea-bottom .counter,
:host(.textarea-disabled) .label-text-wrapper {
color: globals.$ion-primitives-neutral-500;
}
// Textarea - Readonly
// ----------------------------------------------------------------
:host(.textarea-readonly) {
--background: #{globals.$ion-primitives-neutral-100};
}

View File

@ -676,7 +676,7 @@ export class Textarea implements ComponentInterface {
} }
render() { render() {
const { inputId, disabled, size, labelPlacement, el, hasFocus } = this; const { inputId, disabled, readonly, size, labelPlacement, el, hasFocus } = this;
const fill = this.getFill(); const fill = this.getFill();
const theme = getIonTheme(this); const theme = getIonTheme(this);
const shape = this.getShape(); const shape = this.getShape();
@ -719,6 +719,7 @@ export class Textarea implements ComponentInterface {
[`textarea-size-${size}`]: true, [`textarea-size-${size}`]: true,
[`textarea-label-placement-${labelPlacement}`]: true, [`textarea-label-placement-${labelPlacement}`]: true,
'textarea-disabled': disabled, 'textarea-disabled': disabled,
'textarea-readonly': readonly,
})} })}
> >
{/** {/**