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

feat(FormControls): updated logic for rendering icons #9132

Merged
merged 12 commits into from May 18, 2023

Conversation

thatblindgeye
Copy link
Contributor

@thatblindgeye thatblindgeye commented May 16, 2023

What: Closes #9023

@srambach @mcarrano currently the Core examples for Form Control shows a Textinput with both a custom icon and a status icon. I put this functionality in React's TextInput, but notTextArea or FormSelect. Do we want to allow multiple icons to be rendered, and if so should it be on all 3 of these components?

Other notes:

  • deprecated Select and TreeViewSearch were both using inputs with the pf-v5-c-form-control class. These both (or just TreeView?) will end up needing to be updated to use SearchInput instead. For now the styling for TreeViewSearch is different as I hardcoded in markup to render the search icon on the right (rather than the left).
  • The autoResize logic in TextArea currently does not work
  • Added a FromControlIcon helper component rather than adding a ___Icon sub-component for TextArea,FormSelect, and TextInput. I can move this to a more applicable directory if need be.

Additional issues:

@thatblindgeye thatblindgeye changed the title Iss9023 form control icons feat(FormControls): updated logic for rendering icons May 16, 2023
@patternfly-build
Copy link
Contributor

patternfly-build commented May 16, 2023

@nicolethoen
Copy link
Contributor

And this will need a code mod, right?

  • props being removed related to iconSprites
  • props being changed related to customIcons
  • the TextInput's isReadOnly prop being removed
  • the new way to handle expandable text areas
  • probably more I missed?

@nicolethoen
Copy link
Contributor

  • The autoResize logic in TextArea currently does not work

@thatblindgeye is this a regression? Is it because of the new DOM structure? Can we fix it w/o a breaking change and maybe make a follow up issue or does it require investigation today?

@thatblindgeye
Copy link
Contributor Author

@nicolethoen Yeah there'll definitely be some codemods needed after this update. I'm going to go through and open an issue(s) for anything I catch.

And I believe it might be due to new structure, but I'm going to investigate a bit more into it.

@srambach
Copy link
Member

srambach commented May 17, 2023

Do we want to allow multiple icons to be rendered, and if so should it be on all 3 of these components?

I don't know of any place that uses an icon (not a status icon) on a text area or select. @mcoker?
The text input definitely needs to support both a custom icon and a status.

The autoResize logic in TextArea currently does not work

This is almost definitely due to the new structure - in order to make sure the icon doesn't float off by itself, the resize was moved out onto the wrapper div rather than the text area itself. Then the text area just takes up as much room as there is. Is there a way to manage auto resize with that?

@thatblindgeye
Copy link
Contributor Author

@nicolethoen @srambach Updated the autoresizing logic. Looks like the previous heightToken isn't actually applied to anything in Core anymore, so now just setting the height on the .pf-v5-c-form-control div.

@srambach
Copy link
Member

srambach commented May 17, 2023

File upload changed a little
image

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

@thatblindgeye this looks mostly good but I did identify some issue. Not sure if these result from this PR or other changes that were made.

  • The header area in the File Upload component is weirdly truncating.

Screenshot 2023-05-17 at 9 33 42 AM

  • For number input, the input fields now have spinners on them, they did not before.

Screenshot 2023-05-17 at 9 42 28 AM

  • For the Time Picker, looks like the icon used inside of the field changed. PF4 was using the outlined clock which was per the original design.

Screenshot 2023-05-17 at 10 36 48 AM

@mcoker
Copy link
Contributor

mcoker commented May 17, 2023

I don't know of any place that uses an icon (not a status icon) on a text area or select. @mcoker?
The text input definitely needs to support both a custom icon and a status.

@srambach @thatblindgeye I'd say let's just support whatever was supported in v4. Applying a custom icon to both select and textarea don't work as expected, so I think we can just keep that feature on textinput

Screenshot 2023-05-17 at 10 15 42 AM

@mcoker
Copy link
Contributor

mcoker commented May 17, 2023

@mcarrano @srambach @thatblindgeye Looks like we're styling the old form control class for things that need to be updated with to style the right element based on the updates made in core to remove the background images. That will account for some of these visual bugs you're seeing @mcarrano. I created an issue to fix those - patternfly/patternfly#5583

@thatblindgeye
Copy link
Contributor Author

@mcarrano I updated the icon on TimePicker. Looks like the other issues should be covered by the issue @mcoker created in Core above.

Copy link
Contributor

@nicolethoen nicolethoen left a comment

Choose a reason for hiding this comment

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

the react code here looks solid

Copy link
Member

@mcarrano mcarrano left a comment

Choose a reason for hiding this comment

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

@mcarrano I updated the icon on TimePicker. Looks like the other issues should be covered by the issue @mcoker created in Core above.

In that case I approve.

@@ -0,0 +1,31 @@
import * as React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know that I would put this component in helpers. I would recommend adding it with rest of our components. Just don't export it.

export const FormControlIcon = ({ status, customIcon, className, ...props }: FormControlIconProps) => {
const StatusIcon = status && statusIcons[status];

return customIcon || StatusIcon ? (
Copy link
Contributor

@tlabaj tlabaj May 17, 2023

Choose a reason for hiding this comment

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

I do not think this check is necessary this is an internal component and will always be set.

@tlabaj
Copy link
Contributor

tlabaj commented May 18, 2023

@mcarrano @srambach @thatblindgeye Looks like we're styling the old form control class for things that need to be updated with to style the right element based on the updates made in core to remove the background images. That will account for some of these visual bugs you're seeing @mcarrano. I created an issue to fix those - patternfly/patternfly#5583

@mcoker is this good to merge as is or do do we want to wait for core bug to be fixed?

@mcoker
Copy link
Contributor

mcoker commented May 18, 2023

@tlabaj no need to wait for core IMO, those updates will not need a react follow up.

Copy link
Contributor

@mcoker mcoker 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 one note about a modifier on <TextInput> that I don't think is necessary.

isDisabled && styles.modifiers.disabled,
isExpanded && styles.modifiers.expanded,
customIcon && styles.modifiers.icon,
placeholder && styles.modifiers.placeholder,
Copy link
Contributor

Choose a reason for hiding this comment

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

This doesn't appear to be necessary, and it looks incorrect in the core docs, too. We style the placeholder (update the color) via ::placeholder (meaning the html element has a placeholder attribute) - https://github.com/patternfly/patternfly/blob/474883c523da6bf7b5bbc44dc415b2d15429565c/src/patternfly/components/FormControl/form-control.scss#L150-L152

We use .pf-m-placeholder on <FormSelect> because a <select> is different and doesn't support placeholder. https://github.com/patternfly/patternfly/blob/474883c523da6bf7b5bbc44dc415b2d15429565c/src/patternfly/components/FormControl/form-control.scss#L277

Copy link
Contributor

@tlabaj tlabaj left a comment

Choose a reason for hiding this comment

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

LGTM!

@tlabaj tlabaj merged commit 9f4863f into patternfly:v5 May 18, 2023
10 checks passed
@patternfly-build
Copy link
Contributor

Your changes have been released in:

  • @patternfly/react-charts@7.0.0-alpha.27
  • @patternfly/react-code-editor@5.0.0-alpha.110
  • @patternfly/react-core@5.0.0-alpha.109
  • @patternfly/react-docs@6.0.0-alpha.117
  • @patternfly/react-icons@5.0.0-alpha.16
  • demo-app-ts@5.0.0-alpha.93
  • @patternfly/react-integration@5.0.0-alpha.47
  • @patternfly/react-styles@5.0.0-alpha.12
  • @patternfly/react-table@5.0.0-alpha.111
  • @patternfly/react-tokens@5.0.0-alpha.11

Thanks for your contribution! 🎉

nicolethoen pushed a commit to Kells512/patternfly-react that referenced this pull request Sep 1, 2023
* feat(FormControls): updated logic for rendering icons

* Updated FormSelect

* Updated TextArea

* Updated treeview search markup

* Updated remaining integration tests

* Updated autoresize logic

* Updated snaphots

* Updated timepicker icon

* Updated FormControlIcon placement and rendering

* Removed placeholder class on Textinput

* Updated snapshots

* Updated snapshots properly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Form control - restructure to support removal of background images icons
10 participants