Skip to content

Commit

Permalink
Revert TextField state styling (#2309)
Browse files Browse the repository at this point in the history
## Summary:
The new focus styling in the TextField can sometimes be cropped off in webapp if an ancestor has overflow: hidden. This 
reverts the changes (commit 982f680) to unblock updating other WB dependencies in webapp (Khan/webapp#25010). A proper fix will be made in a follow up PR!

Ran: `git revert 982f680`


Issue: WB-1746

## Test plan:
1. Confirm TextField styling is the same as before (ie. no additional focus outline) (`?path=/story/packages-form-textfield--default`)
<img width="547" alt="image" src="https://github.com/user-attachments/assets/3104bd43-29c9-4ef6-8c94-595d4cd8fe7b">

Author: beaesguerra

Reviewers: jandrade, beaesguerra

Required Reviewers:

Approved By: jandrade

Checks: ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test (ubuntu-latest, 20.x, 2/2), ✅ Test (ubuntu-latest, 20.x, 1/2), ✅ Lint (ubuntu-latest, 20.x), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ✅ Chromatic - Get results on regular PRs (ubuntu-latest, 20.x), ✅ Test (ubuntu-latest, 20.x, 2/2), ✅ Lint (ubuntu-latest, 20.x), ✅ Test (ubuntu-latest, 20.x, 1/2), ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x), ✅ gerald, ✅ Check build sizes (ubuntu-latest, 20.x), ✅ Test (ubuntu-latest, 20.x, 2/2), ✅ Lint (ubuntu-latest, 20.x), ✅ Test (ubuntu-latest, 20.x, 1/2), ✅ Chromatic - Build on regular PRs / chromatic (ubuntu-latest, 20.x), ⏭️  Chromatic - Skip on Release PR (changesets), 🚫 Chromatic - Get results on regular PRs, ⏭️  Publish npm snapshot, ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ gerald, ⌛ undefined

Pull Request URL: #2309
  • Loading branch information
beaesguerra authored Aug 28, 2024
1 parent 326954d commit 9ec147a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 253 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilled-pumpkins-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@khanacademy/wonder-blocks-form": patch
---

Revert updated `TextField` state styling
168 changes: 0 additions & 168 deletions __docs__/wonder-blocks-form/text-field-variants.stories.tsx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {render, screen, fireEvent} from "@testing-library/react";
import {userEvent} from "@testing-library/user-event";

import {StyleSheet} from "aphrodite";
import {color} from "@khanacademy/wonder-blocks-tokens";
import LabeledTextField from "../labeled-text-field";

describe("LabeledTextField", () => {
Expand Down Expand Up @@ -381,6 +382,28 @@ describe("LabeledTextField", () => {
expect(input).toBeInTheDocument();
});

it("light prop is passed to textfield", async () => {
// Arrange

// Act
render(
<LabeledTextField
label="Label"
value=""
onChange={() => {}}
light={true}
/>,
);

const textField = await screen.findByRole("textbox");
textField.focus();

// Assert
expect(textField).toHaveStyle({
boxShadow: `0px 0px 0px 1px ${color.blue}, 0px 0px 0px 2px ${color.white}`,
});
});

it("style prop is passed to fieldheading", async () => {
// Arrange
const styles = StyleSheet.create({
Expand Down
6 changes: 3 additions & 3 deletions packages/wonder-blocks-form/src/components/text-area.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from "react";
import {StyleSheet} from "aphrodite";
import {CSSProperties, Falsy, StyleSheet} from "aphrodite";

import {
AriaProps,
Expand Down Expand Up @@ -256,7 +256,7 @@ const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
}
});

const getStyles = (): StyleType => {
const getStyles = (): (CSSProperties | Falsy)[] => {
// Base styles are the styles that apply regardless of light mode
const baseStyles = [
styles.textarea,
Expand Down Expand Up @@ -284,7 +284,7 @@ const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
data-testid={testId}
ref={ref}
className={className}
style={[getStyles(), style]}
style={[...getStyles(), style]}
value={value}
onChange={handleChange}
placeholder={placeholder}
Expand Down
Loading

0 comments on commit 9ec147a

Please sign in to comment.