Skip to content
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

TextField component updates #16424

Merged
merged 8 commits into from
Nov 10, 2022
Merged

TextField component updates #16424

merged 8 commits into from
Nov 10, 2022

Conversation

georgewrmarshall
Copy link
Contributor

@georgewrmarshall georgewrmarshall commented Nov 9, 2022

Explanation

What is the current state of things and why does it need to change?
The current TextField component handles the clear button logic but this was actually breaking the component when value was changed outside of the onChange function. It also limits the flexibility of the component.

What is the solution your changes offer and how does it work?

  • Updating the name of the showClear prop to showClearButton which is more specific
  • Reducing the logic used inside of the component in favour of letting the engineer handle it for each usecase
  • Updating the stories and docs to reflect these changes
  • Updating unit tests to reflect these changes as well as improving the quality of the tests by using userEvent

Screenshots/Screencaps

Before

text.field.before.mov

After

text.field.after.mov

Manual Testing Steps

  • Go to the latest build of storybook in this PR
  • Search TextField in the search bar (make sure it's under the Component Library section)
  • Check the controls and docs

For unit tests

  • Checkout this branch
  • Run yarn test:unit:jest ui/components/component-library/text-field/text-field.test.js

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 9, 2022

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@georgewrmarshall georgewrmarshall changed the title Updating showClearButton prop name and making component dumber TextField component updates Nov 9, 2022
@georgewrmarshall georgewrmarshall self-assigned this Nov 9, 2022
@georgewrmarshall georgewrmarshall added area-UI Relating to the user interface. team-design-system All issues relating to design system in Extension IA/NAV labels Nov 9, 2022
/**
* The props to pass to the icon inside of the close button
*/
clearButtonIconProps: PropTypes.shape(Icon.PropTypes),
Copy link
Contributor Author

@georgewrmarshall georgewrmarshall Nov 9, 2022

Choose a reason for hiding this comment

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

Removing clearButtonIconProps because this doesn't exist now that we are using ButtonIcon

@georgewrmarshall georgewrmarshall marked this pull request as ready for review November 9, 2022 01:22
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner November 9, 2022 01:22
Copy link
Member

@NidhiKJha NidhiKJha left a comment

Choose a reason for hiding this comment

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

Just a small nit for tests

@metamaskbot
Copy link
Collaborator

Builds ready [5cf8830]
Page Load Metrics (2429 ± 163 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1022291402914
domContentLoaded184631932396341164
load192831942429339163
domInteractive184631932396341164
Bundle size diffs
  • background: 0 bytes
  • ui: 0 bytes
  • common: 0 bytes

highlights:

storybook

garrettbear
garrettbear previously approved these changes Nov 10, 2022
expect(onClear).toHaveBeenCalledTimes(1);
expect(onClick).toHaveBeenCalledTimes(1);
await user.click(getByRole('button', { name: /Clear/u }));
expect(fn).toHaveBeenCalledTimes(1);
});
it('should be able to accept inputProps', () => {
const { getByRole } = render(
Copy link
Contributor Author

@georgewrmarshall georgewrmarshall Nov 10, 2022

Choose a reason for hiding this comment

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

When running these tests locally you may run into this propType issue. It's a known issue and I have an open PR that, with the gracious help of @Gudahtt we are still trying to work through #16078

Screen Shot 2022-11-09 at 7 33 04 PM

NidhiKJha
NidhiKJha previously approved these changes Nov 10, 2022
@metamaskbot
Copy link
Collaborator

Builds ready [938e5b5]
Page Load Metrics (2627 ± 175 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint10082618715474
domContentLoaded196433072604349167
load197733072627365175
domInteractive196433072603349167
Bundle size diffs
  • background: 0 bytes
  • ui: 0 bytes
  • common: 0 bytes

highlights:

storybook

@garrettbear garrettbear merged commit 9821c59 into develop Nov 10, 2022
@garrettbear garrettbear deleted the text-field-updates branch November 10, 2022 19:13
@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-UI Relating to the user interface. team-design-system All issues relating to design system in Extension
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants