-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Adding TextFieldSearch
component
#16296
Conversation
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. |
I see that this is |
There was a problem hiding this 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
ui/components/component-library/text-field-search/text-field-search.stories.js
Outdated
Show resolved
Hide resolved
ui/components/component-library/text-field-search/text-field-search.test.js
Outdated
Show resolved
Hide resolved
TextFieldSearch
component
0c295a3
to
bb619cb
Compare
@@ -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 | |||
*/ |
There was a problem hiding this comment.
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 ( |
There was a problem hiding this comment.
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
); | ||
}; | ||
return { user: userEvent.setup(), ...render(<ControlledWrapper />) }; | ||
} |
There was a problem hiding this comment.
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
// 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 />) }; | ||
} | ||
|
There was a problem hiding this comment.
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
ui/components/component-library/text-field-search/text-field-search.js
Outdated
Show resolved
Hide resolved
ui/components/component-library/text-field-search/text-field-search.js
Outdated
Show resolved
Hide resolved
d7fa159
Builds ready [d7fa159]
Page Load Metrics (2314 ± 147 ms)
Bundle size diffs
highlights:storybook
|
Explanation
Adding
TextFieldSearch
component to be used for all search inputsMore Information
Screenshots/Screencaps
After
textfieldsearch.mov
Manual Testing Steps
TextFieldSearch
in the search barPre-Merge Checklist
+ If there are functional changes:
Acceptance Criteria
className
prop and the PropType descriptions are all the samesize
and are suggesting the use of the generalizeddesign-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 onlyimgSrc
,imgAlt
(html element + attribute) (needs audit)size
prop would beexport const Size = (args) => (
size
prop would be### Size
mm-
prefix to all classNames// TODO:
comment so we can search for them at a later date e.g. blocking components etc