Skip to content

Commit

Permalink
fix(pager): fix bottom margin of number input when inside a form
Browse files Browse the repository at this point in the history
Ensure the "current page" input field of Pager always has margin-bottom 0, even when inside a form.

fix #5650
  • Loading branch information
robinzigmond committed Dec 6, 2022
1 parent 625ebff commit 242d29c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cypress/locators/pager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
PAGER_LAST_ARROW,
SHOW_LABEL_BEFORE,
PAGE_SIZE_LABEL_AFTER,
CURRENT_PAGE,
} from "./locators";
import { COMMMON_DATA_ELEMENT_INPUT } from "../locators";
import { getDataElementByValue } from "..";
Expand All @@ -19,6 +20,7 @@ export const pageSelect = () =>
cy.get(PAGE_SELECT).find(COMMMON_DATA_ELEMENT_INPUT);
export const pageSelectElement = () => cy.get(PAGE_SELECT);
export const maxPages = () => cy.get(MAX_PAGES);
export const currentPageWrapper = () => cy.get(CURRENT_PAGE);
export const currentPageInput = () => cy.get(PAGER_SUMMARY).find("input");
export const previousArrow = () =>
getDataElementByValue(`${COMMON_PART_OF_PAGER_LINK}${PAGER_PREVIOUS_ARROW}`);
Expand Down
1 change: 1 addition & 0 deletions cypress/locators/pager/locators.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export const PAGER_LAST_ARROW = "last";
export const COMMON_PART_OF_PAGER_LINK = "pager-link-";
export const SHOW_LABEL_BEFORE = "Show";
export const PAGE_SIZE_LABEL_AFTER = "items";
export const CURRENT_PAGE = '[data-element="current-page"]';
2 changes: 1 addition & 1 deletion src/components/pager/pager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ describe("Pager", () => {
assertStyleMatch(
{ marginBottom: "0" },
wrapper.find(StyledPagerNavInner),
{ modifier: `${StyledFormField}` }
{ modifier: `&& ${StyledFormField}` }
);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/pager/pager.style.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const StyledPagerNavInner = styled.div`
align-items: center;
padding: 0 12px;
& ${StyledFormField} {
&& ${StyledFormField} {
margin-bottom: 0;
}
`;
Expand Down
18 changes: 18 additions & 0 deletions src/components/pager/pager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
nextArrow,
firstArrow,
lastArrow,
currentPageWrapper,
currentPageInput,
pagerSummary,
pageSelectElement,
Expand All @@ -22,6 +23,7 @@ import { keyCode } from "../../../cypress/support/helper";
import useMediaQuery from "../../hooks/useMediaQuery";
import { checkGoldenOutline } from "../../../cypress/support/component-helper/common-steps";
import { CHARACTERS } from "../../../cypress/support/component-helper/constants";
import Form from "../form";

const testData = [CHARACTERS.DIACRITICS, CHARACTERS.SPECIALCHARACTERS];
const records = [
Expand Down Expand Up @@ -139,6 +141,14 @@ const PagerComponentResponsive = () => {
);
};

const PagerInForm = () => {
return (
<Form>
<PagerComponent />
</Form>
);
};

context("Test for Pager component", () => {
describe("check props for Pager component", () => {
it.each([[2], [5], [7]])(
Expand Down Expand Up @@ -532,4 +542,12 @@ context("Test for Pager component", () => {
}
);
});

describe("when inside a form component", () => {
it("should have no bottom margin", () => {
CypressMountWithProviders(<PagerInForm />);

currentPageWrapper().should("have.css", "margin-bottom", "0px");
});
});
});

0 comments on commit 242d29c

Please sign in to comment.