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

fix(form-control): move borders to pseudo element, remove extra css #5641

Merged
merged 8 commits into from Jun 1, 2023

Conversation

mcoker
Copy link
Contributor

@mcoker mcoker commented Jun 1, 2023

Updates the form control to move the borders to pseudo elements, remove all of the custom height and padding calc()s that were needed to offset the borders since they were part of the component layout.

@mcoker mcoker requested a review from thatblindgeye June 1, 2023 04:24
@patternfly-build
Copy link

patternfly-build commented Jun 1, 2023

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

🎉

--#{$form-control}--after--BorderRightWidth: var(--#{$pf-global}--BorderWidth--sm);
--#{$form-control}--after--BorderBottomWidth: var(--#{$pf-global}--BorderWidth--sm);
--#{$form-control}--after--BorderLeftWidth: var(--#{$pf-global}--BorderWidth--sm);
--#{$form-control}--after--BorderWidth: var(--#{$pf-global}--BorderWidth--sm);
Copy link
Contributor

Choose a reason for hiding this comment

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

One small thing, doesn't look like this after--BorderWidth var is being used anywhere

@mcoker mcoker requested a review from mattnolting June 1, 2023 15:02
@mcoker mcoker requested a review from srambach June 1, 2023 15:07
@srambach
Copy link
Member

srambach commented Jun 1, 2023

FWIW, the focus ring is narrower than it was previously - but now you can see the status color bottom border. It also removes the little artifact at the corner, which is nice.
image

@srambach
Copy link
Member

srambach commented Jun 1, 2023

I think on line 90, --#{$form-control}--textarea--Height can also be removed?

Similar to the previous comment, the focus ring is also cut off when next to something, like in the date picker.
image

Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

Generally this looks good but for a few nits and the focus ring question.
Also, just for discussion - using --after is consistent with our model, but when I was refactoring the cards we talked about using more logical names to keep future things non-breaking and perhaps ease token use. E.g., if we kept the border variables as is, we could move them between the wrapper or the pseudo-element or whatever clever thing we came up with, without causing a breaking change. WDYT?

}
}

&:hover {
--#{$form-control}--BorderBottomColor: var(--#{$form-control}--hover--BorderBottomColor);
--#{$form-control}--after--after--BorderBottomColor: var(--#{$form-control}--hover--after--BorderBottomColor);
Copy link
Member

Choose a reason for hiding this comment

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

Search and replace oops? (--after--after)

@mcoker
Copy link
Contributor Author

mcoker commented Jun 1, 2023

@srambach thanks for the review! Should have addressed everything but the focus ring. Dark theme vars also needed to be updated, moved the :focus styles to :focus-within, and fixed focus styles appearing incorrectly in the readonly input.

Re: the focus ring... a few thoughts. I'll note that from glancing, the focus ring looks the same in menu toggle and control buttons, which have the same look.

  • The lack of focus ring date picker is from the input group. The input group moves any * + * child to the left by 1px, to prevent double-borders when putting form-things side by side. So if you focus on anything that has a sibling after it in the input group layout, the sibling component will be on top of the focused component. We had this style previously to address that, we could add it back. wdyt? cc @mattnolting

    > :focus,
    > :focus-within {
    z-index: var(--pf-c-input-group--child--ZIndex);
    }

  • One solution could be to adjust the outline-offset - that would move the focus ring inside - it would need to be inside now because the textarea controls overflow with overflow: auto; and that will hide the outline if it goes outside of the box.

  • An easier solution could be to manage the stacking context:

    • move the border to ::before and add position: relative or isolation: isolate to the input/textarea/select
    • keep the borders on ::after and add our xs z-index on the form element. I'd probably prefer this as a solution - ideally I think the grey borders for the form control should be on the ::before and the status/bottom border should be on ::after so they can be drawn separately and not create an angled corner like they do now. This is how the menu toggle is setup currently.

Copy link
Contributor

@mattnolting mattnolting left a comment

Choose a reason for hiding this comment

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

I think moving the borders to a pseudo is a good idea, but typically we add gray, static borders to ::before and accent/hover borders to ::after to avoid bevelled borders

Screenshot 2023-06-01 at 2 43 03 PM

Screenshot 2023-06-01 at 2 43 03 PM

@srambach
Copy link
Member

srambach commented Jun 1, 2023

I don't hate moving the outline-offset in about 2px. That gives the full focus ring, the width is consistent with other focus rings other than the ones you mention (which then could be updated as well), and still shows the status bottom border color. Do you know of any problems it creates?

@mcoker mcoker requested a review from mattnolting June 1, 2023 20:27
@srambach
Copy link
Member

srambach commented Jun 1, 2023

If the text area is resized, the focus ring isn't stretching properly.
image

Copy link
Member

@srambach srambach left a comment

Choose a reason for hiding this comment

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

👍

Copy link
Contributor

@mattnolting mattnolting left a comment

Choose a reason for hiding this comment

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

Thanks for updating, LPTM!!

@mcoker mcoker merged commit 2a4530b into patternfly:v5 Jun 1, 2023
1 check passed
@patternfly-build
Copy link

🎉 This PR is included in version 5.0.0-alpha.75 🎉

The release is available on:

Your semantic-release bot 📦🚀

mattnolting pushed a commit to mattnolting/patternfly that referenced this pull request Dec 12, 2023
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.

None yet

5 participants