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

InputBase: Add isBorderless prop #58750

Merged
merged 4 commits into from
Feb 7, 2024
Merged

InputBase: Add isBorderless prop #58750

merged 4 commits into from
Feb 7, 2024

Conversation

mirka
Copy link
Member

@mirka mirka commented Feb 6, 2024

Prerequisite for #56524 and possibly #57720

What?

Adds a isBorderless prop to the internal InputBase component, and connects the component to the Context System so it can also be toggled "under the table".

Why?

Some recent design specs require the border to be hidden in certain components (e.g. SearchControl, maybe SelectControl).

We don't quite want to surface this as an official prop on public components themselves because they require careful holistic assessment in terms of accessibility. But it's useful to have as a semi-private prop on an internal building block like InputBase.

Testing Instructions

Apply this diff to test

diff --git a/packages/components/src/input-control/input-base.tsx b/packages/components/src/input-control/input-base.tsx
index ec468ce7fd..bf68458720 100644
--- a/packages/components/src/input-control/input-base.tsx
+++ b/packages/components/src/input-control/input-base.tsx
@@ -77,7 +77,7 @@ export function InputBase(
 		hideLabelFromVision = false,
 		labelPosition,
 		id: idProp,
-		isBorderless = false,
+		isBorderless = true,
 		isFocused = false,
 		label,
 		prefix,

Apply the diff above and see the Storybook for some InputBase-based components, like InputControl or SelectControl.

Screenshots or screencast

This is just an example of what happens when the borderless flag is enabled in an InputBase-based component, in this case SelectControl. Obviously, other design/accessibility considerations need to be taken into account before shipping this in a public component.

SelectControl unfocused and focused

@mirka mirka added [Type] Enhancement A suggestion for improvement. [Package] Components /packages/components labels Feb 6, 2024
@mirka mirka self-assigned this Feb 6, 2024
@mirka mirka requested a review from ajitbohra as a code owner February 6, 2024 19:00
Copy link

github-actions bot commented Feb 6, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core SVN

Core Committers: Use this line as a base for the props when committing in SVN:

Props 0mirka00, mciampini.

GitHub Merge commits

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: mirka <[email protected]>
Co-authored-by: ciampo <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

disabled = false,
isBorderless = false,
isFocused = false,
} ) {
return (
<BackdropUI
aria-hidden="true"
className="components-input-control__backdrop"
Copy link
Member Author

Choose a reason for hiding this comment

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

Technically, we can already just use this .components-input-control__backdrop selector to override border styles from any consumer. Still, I think it's better to control this centrally because it's intertwined with the border styles in the focused and disabled states, as you can see in the input-control-styles.tsx file.

Comment on lines +179 to +184
/**
* Whether to hide the border when not focused.
*
* @default false
*/
isBorderless?: boolean;
Copy link
Member Author

Choose a reason for hiding this comment

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

This prop shouldn't be exposed in the APIs of any public component.

@@ -213,7 +213,7 @@ export const Input = styled.input< InputProps >`
box-sizing: border-box;
border: none;
box-shadow: none !important;
color: ${ COLORS.gray[ 900 ] };
color: ${ COLORS.theme.foreground };
Copy link
Member Author

Choose a reason for hiding this comment

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

Unrelated to borderless, but I'd like to sneak in this small enhancement for better themability if that's ok 🥺

@mirka mirka requested a review from a team February 6, 2024 19:17
Copy link

github-actions bot commented Feb 6, 2024

Flaky tests detected in 4f38523.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7805003098
📝 Reported issues:

Copy link
Contributor

@ciampo ciampo left a comment

Choose a reason for hiding this comment

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

🚀

@mirka mirka merged commit 87c5697 into trunk Feb 7, 2024
58 checks passed
@mirka mirka deleted the input-base-borderless branch February 7, 2024 11:20
@github-actions github-actions bot added this to the Gutenberg 17.7 milestone Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants