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(InputGroupText): drop variants and fix missing padding because of wrong classes #8953

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions packages/react-core/src/components/InputGroup/InputGroupText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,29 @@ import * as React from 'react';
import styles from '@patternfly/react-styles/css/components/InputGroup/input-group';
import { css } from '@patternfly/react-styles';

export enum InputGroupTextVariant {
default = 'default',
plain = 'plain'
}
Comment on lines -5 to -8
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we would want to remove this enum and the variant prop. Part of what the plain variant should be doing is removing that bottom border from pf-c-input-group__item. My comment below mentions it as well, but it looks like the cause of the padding issue might be the markup not matching Core. @srambach wdyt (including my other comment below)?

Copy link
Member

Choose a reason for hiding this comment

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

I think we want to keep the option to make it plain or not, and I agree that the problem seems to be that the markup is slightly different as @thatblindgeye comments below.


export interface InputGroupTextProps extends React.HTMLProps<HTMLSpanElement | HTMLLabelElement> {
/** Additional classes added to the input group text. */
className?: string;
/** Content rendered inside the input group text. */
children: React.ReactNode;
/** Component that wraps the input group text. */
component?: React.ReactNode;
/** Input group text variant */
variant?: InputGroupTextVariant | 'default' | 'plain';
}

export const InputGroupText: React.FunctionComponent<InputGroupTextProps> = ({
className = '',
component = 'span',
children,
variant = InputGroupTextVariant.default,
...props
}: InputGroupTextProps) => {
const Component = component as any;
return (
<Component
className={css(
styles.inputGroupItem,
styles.inputGroupText,
variant === InputGroupTextVariant.plain && styles.modifiers.plain,
styles.modifiers.plain,
styles.modifiers.box,
Comment on lines +24 to +27
Copy link
Contributor

Choose a reason for hiding this comment

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

This is causing differences in the markup compared to Core. In Core the markup is:

Core markup for InputGroup

This PR the markup becomes:

PR preview markup for InputGroup

className
)}
{...props}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React from 'react';

import { render, screen } from '@testing-library/react';

import { InputGroupText, InputGroupTextVariant } from '../InputGroupText';
import { InputGroupText } from '../InputGroupText';

describe('InputGroupText', () => {
test('renders', () => {
render(
<InputGroupText className="inpt-grp-text" variant={InputGroupTextVariant.plain} id="email-npt-grp">
<InputGroupText className="inpt-grp-text" id="email-npt-grp">
@
</InputGroupText>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import AtIcon from '@patternfly/react-icons/dist/esm/icons/at-icon';
import { InputGroup, InputGroupText, InputGroupTextVariant, TextInput, ValidatedOptions } from '@patternfly/react-core';
import { InputGroup, InputGroupText, TextInput, ValidatedOptions } from '@patternfly/react-core';

export const InputGroupBasic: React.FunctionComponent = () => (
<React.Fragment>
Expand All @@ -23,7 +23,7 @@ export const InputGroupBasic: React.FunctionComponent = () => (
<br />
<InputGroup>
<TextInput name="textInput-basic-3" id="textInput-basic-3" type="text" aria-label="percentage" />
<InputGroupText id="plain-example" variant={InputGroupTextVariant.plain}>
<InputGroupText id="plain-example">
%
</InputGroupText>
</InputGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ exports[`slider renders slider with input 1`] = `
value="50"
/>
<span
class="pf-c-input-group__text"
class="pf-c-input-group__item pf-c-input-group__text pf-m-plain pf-m-box"
>
%
</span>
Expand Down Expand Up @@ -492,7 +492,7 @@ exports[`slider renders slider with input above thumb 1`] = `
value="50"
/>
<span
class="pf-c-input-group__text"
class="pf-c-input-group__item pf-c-input-group__text pf-m-plain pf-m-box"
>
%
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
TextArea,
InputGroup,
InputGroupText,
InputGroupTextVariant,
TextInput,
Popover,
PopoverPosition,
Expand Down Expand Up @@ -168,7 +167,7 @@ export class InputGroupDemo extends React.Component<{}, InputGroupState> {
<br />
<InputGroup>
<TextInput name="textIndex12" id="textInput12" type="text" aria-label="percentage" />
<InputGroupText id="plain-example" variant={InputGroupTextVariant.plain}>
<InputGroupText id="plain-example">
%
</InputGroupText>
</InputGroup>
Expand Down