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

Adding TextFieldSearch component #16296

Merged
merged 4 commits into from
Nov 15, 2022

Conversation

georgewrmarshall
Copy link
Contributor

@georgewrmarshall georgewrmarshall commented Oct 27, 2022

Explanation

Adding TextFieldSearch component to be used for all search inputs

More Information

Screenshots/Screencaps

After

textfieldsearch.mov

Manual Testing Steps

  • Go to the latest build of Storybook in this PR
  • Search TextFieldSearch in the search bar
  • Check story controls
  • Check stories
  • Check docs

Pre-Merge Checklist

  • PR template is filled out
  • IF this PR fixes a bug, a test that would have caught the bug has been added
  • PR is linked to the appropriate GitHub issue
  • PR has been added to the appropriate release Milestone

+ If there are functional changes:

  • Manual testing complete & passed
  • "Extension QA Board" label has been applied

Acceptance Criteria

  • Has a className prop and the PropType descriptions are all the same
  • Prop table in MDX docs have the "Accepts all Box component props" description and link
  • We are consistent when using the same prop names like size and are suggesting the use of the generalized design-system.js constants e.g. SIZES as the primary option but noting the component consts in the documentation and using them for propType validation and storybook controls only
  • Standardize all similar prop names for images imgSrc, imgAlt(html element + attribute) (needs audit)
  • We have a story for each component prop and we use the prop name verbatim e.g. size prop would be export const Size = (args) => (
  • We have the accompanying documentation for each component prop and we use the prop name verbatim e.g. size prop would be ### Size
  • Add mm- prefix to all classNames
  • className is kebab case version of the component name
  • Spread base components props and reduce duplication of props when props aren't being changed and remain the same for both variant and base components
  • Add any "to dos" with a // TODO: comment so we can search for them at a later date e.g. blocking components etc

@georgewrmarshall georgewrmarshall added area-UI Relating to the user interface. team-design-system All issues relating to design system in Extension IA/NAV labels Oct 27, 2022
@georgewrmarshall georgewrmarshall self-assigned this Oct 27, 2022
@github-actions
Copy link
Contributor

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 Adding TextFieldSearch component Adding TextFieldSearch component (WIP) Oct 27, 2022
@georgewrmarshall georgewrmarshall marked this pull request as ready for review October 27, 2022 21:58
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner October 27, 2022 21:58
@georgewrmarshall georgewrmarshall requested review from adonesky1, garrettbear and NidhiKJha and removed request for adonesky1 October 27, 2022 21:58
@georgewrmarshall georgewrmarshall changed the title Adding TextFieldSearch component (WIP) Adding TextFieldSearch component Oct 27, 2022
@darkwing
Copy link
Contributor

darkwing commented Nov 4, 2022

I see that this is type=text. Should we make this type=search for accessibility purposes, and then shim away special styles given to it by each browser/OS? Or maybe not? https://adrianroselli.com/2019/07/ignore-typesearch.html. ; just a thought.

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.

LGTM! Just a small fix

@georgewrmarshall georgewrmarshall marked this pull request as draft November 8, 2022 18:12
@georgewrmarshall georgewrmarshall changed the title Adding TextFieldSearch component Adding TextFieldSearch component Nov 9, 2022
@georgewrmarshall georgewrmarshall force-pushed the feat/15100/text-field-search-component branch from 0c295a3 to bb619cb Compare November 10, 2022 23:00
@@ -75,7 +73,7 @@ TextField.propTypes = {
/**
* The props to pass to the clear button
*/
clearButtonProps: PropTypes.shape(Box.PropTypes),
clearButtonProps: PropTypes.shape(ButtonIcon.PropTypes),
/**
* TextField accepts all the props from TextFieldBase and Box
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Missed this update, but these no longer need to be required because this can operate as an uncontrolled component. It is only when showClearButton is true that these are required

@@ -16,7 +16,7 @@ function setup(jsx) {

// Custom userEvent setup function that renders the component in a controlled environment.
// This is used for the showClearButton and related props as the clearButton will only show in a controlled environment.
function setupControlled(FormComponent, props) {
export default function setupControlled(FormComponent, props) {
const ControlledWrapper = () => {
const [value, setValue] = useState('');
return (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use this function in the ui/components/component-library/text-field-search/text-field-search.test.js

@georgewrmarshall georgewrmarshall marked this pull request as ready for review November 10, 2022 23:07
);
};
return { user: userEvent.setup(), ...render(<ControlledWrapper />) };
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving the controlled render setup function to testing utils

Comment on lines -17 to -32
// Custom userEvent setup function that renders the component in a controlled environment.
// This is used for the showClearButton and related props as the clearButton will only show in a controlled environment.
function setupControlled(FormComponent, props) {
const ControlledWrapper = () => {
const [value, setValue] = useState('');
return (
<FormComponent
value={value}
onChange={(e) => setValue(e.target.value)}
{...props}
/>
);
};
return { user: userEvent.setup(), ...render(<ControlledWrapper />) };
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moving to test/lib/render-helpers.js

@metamaskbot
Copy link
Collaborator

Builds ready [e429fca]
Page Load Metrics (2097 ± 119 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint911771152210
domContentLoaded167223432078230111
load167224032097249119
domInteractive167223432078230111
Bundle size diffs
  • background: 0 bytes
  • ui: 0 bytes
  • common: 0 bytes

highlights:

storybook

garrettbear
garrettbear previously approved these changes Nov 14, 2022
@georgewrmarshall georgewrmarshall dismissed stale reviews from garrettbear and ghost via d7fa159 November 15, 2022 00:26
@metamaskbot
Copy link
Collaborator

Builds ready [d7fa159]
Page Load Metrics (2314 ± 147 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1061882261407196
domContentLoaded188230332291298143
load188230332314307147
domInteractive188230332291298143
Bundle size diffs
  • background: 0 bytes
  • ui: 0 bytes
  • common: 0 bytes

highlights:

storybook

@georgewrmarshall georgewrmarshall merged commit 6907c4a into develop Nov 15, 2022
@georgewrmarshall georgewrmarshall deleted the feat/15100/text-field-search-component branch November 15, 2022 16:49
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 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.

[Ext Nav] Create component: TextFieldSearch
5 participants