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:icon align when datatype is of image #35992

Merged
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
53 changes: 53 additions & 0 deletions app/client/src/widgets/BaseInputWidget/component/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from "react";
import { render } from "@testing-library/react";
import "@testing-library/jest-dom/extend-expect";
import BaseInputComponent, { type BaseInputComponentProps } from "./index";
import { ThemeProvider } from "styled-components";
import { lightTheme } from "selectors/themeSelectors";

const renderBaseInputComponent = (
props: Partial<BaseInputComponentProps> = {},
) => {
const defaultProps: BaseInputComponentProps = {
value: "",
inputType: "TEXT",
inputHTMLType: "TEXT",
disabled: false,
isLoading: false,
compactMode: false,
isInvalid: false,
label: "Salary",
showError: false,
onValueChange: jest.fn(),
onFocusChange: jest.fn(),
widgetId: "test-widget",
rtl: true,
};

return render(
<ThemeProvider theme={lightTheme}>
<BaseInputComponent {...defaultProps} {...props} />
</ThemeProvider>,
);
};

describe("BaseInputComponent TestCases", () => {
test("1. Icon should be visible and aligned to the right when the input type is a number", () => {
const { container } = renderBaseInputComponent({
inputType: "NUMBER",
inputHTMLType: "NUMBER",
value: "123",
onStep: jest.fn(),
rtl: false,
shouldUseLocale: true,
iconName: "add",
iconAlign: "right",
});

const numericInputIcon = container.getElementsByClassName(
"bp3-icon bp3-icon-add",
)[0];

expect(numericInputIcon).toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions app/client/src/widgets/BaseInputWidget/component/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,7 @@ class BaseInputComponent extends React.Component<
onKeyUp={this.onKeyUp}
onValueChange={this.onNumberChange}
placeholder={this.props.placeholder}
rightElement={this.getRightIcon()}
stepSize={this.props.stepSize}
value={this.props.value}
{...conditionalProps}
Expand Down