Skip to content

Commit

Permalink
feat(select): remove support for rendering list to left and right of …
Browse files Browse the repository at this point in the history
…input

Removes `left` and `right` options from `listPlacement` type, only `top` and `bottom` remain
supported

BREAKING CHANGE: `listPlacement` prop only supports `top` and `bottom` now
  • Loading branch information
edleeks87 committed Sep 26, 2024
1 parent cbed470 commit 28670f6
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface SelectListProps {
/** When true component will work in multi column mode, children should consist of OptionRow components in this mode */
multiColumn?: boolean;
/** Placement of the select list relative to the input element */
listPlacement?: Side;
listPlacement?: "top" | "bottom";
/** Use the opposite list placement if the set placement does not fit */
flipEnabled?: boolean;
/** @private @ignore
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect, useRef, useCallback } from "react";
import invariant from "invariant";
import { Side } from "@floating-ui/dom";

import { ButtonProps } from "../../button";
import { filterOutStyledSystemSpacingProps } from "../../../style/utils";
Expand Down Expand Up @@ -73,7 +72,7 @@ export interface FilterableSelectProps
/** Maximum list height - defaults to 180 */
listMaxHeight?: number;
/** Placement of the select list in relation to the input element */
listPlacement?: Side;
listPlacement?: "top" | "bottom";
/** Use the opposite list placement if the set placement does not fit */
flipEnabled?: boolean;
/** Set this prop to enable a virtualised list of options. If it is not used then all options will be in the
Expand Down
10 changes: 0 additions & 10 deletions src/components/select/filterable-select/filterable-select.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,6 @@ test.describe("FilterableSelect component", () => {
([
["top", "0px", "0px", "0px", "20px"],
["bottom", "600px", "0px", "0px", "20px"],
["left", "200px", "0px", "0px", "900px"],
["right", "200px", "0px", "500px", "20px"],
] as [
FilterableSelectProps["listPlacement"],
string,
Expand Down Expand Up @@ -864,12 +862,6 @@ test.describe("FilterableSelect component", () => {
if (position === "bottom") {
flipPosition = "top";
}
if (position === "left") {
flipPosition = "right";
}
if (position === "right") {
flipPosition = "left";
}
await dropdownButton(page).click();
const listElement = selectListPosition(page);
await expect(listElement).toHaveAttribute(
Expand Down Expand Up @@ -2005,8 +1997,6 @@ test.describe("Accessibility tests for FilterableSelect component", () => {
([
["top", "0px", "0px", "0px", "20px"],
["bottom", "600px", "0px", "0px", "20px"],
["left", "200px", "0px", "0px", "900px"],
["right", "200px", "0px", "500px", "20px"],
] as [
FilterableSelectProps["listPlacement"],
string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ describe("FilterableSelect", () => {
).toBeVisible();
});

it.each(["top", "bottom", "right", "left"])(
it.each(["top", "bottom"])(
"the listPlacement prop should be passed",
(listPlacement) => {
const wrapper = renderSelect({ listPlacement });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export interface MultiSelectProps
/** Maximum list height - defaults to 180 */
listMaxHeight?: number;
/** Placement of the select list in relation to the input element */
listPlacement?: Side;
listPlacement?: "top" | "bottom";
/** Use the opposite list placement if the set placement does not fit */
flipEnabled?: boolean;
/** Wraps the pill text when it would overflow the input width */
Expand Down
10 changes: 0 additions & 10 deletions src/components/select/multi-select/multi-select.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,6 @@ test.describe("MultiSelect component", () => {
([
["top", "0px", "0px", "0px", "20px"],
["bottom", "600px", "0px", "0px", "20px"],
["left", "200px", "0px", "0px", "900px"],
["right", "200px", "0px", "500px", "20px"],
] as [
MultiSelectProps["listPlacement"],
string,
Expand Down Expand Up @@ -766,12 +764,6 @@ test.describe("MultiSelect component", () => {
if (position === "bottom") {
flipPosition = "top";
}
if (position === "left") {
flipPosition = "right";
}
if (position === "right") {
flipPosition = "left";
}
await dropdownButton(page).click();
const listElement = selectListPosition(page);
await expect(listElement).toHaveAttribute(
Expand Down Expand Up @@ -1838,8 +1830,6 @@ test.describe("Accessibility tests for MultiSelect component", () => {
([
["top", "0px", "0px", "0px", "20px"],
["bottom", "600px", "0px", "0px", "20px"],
["left", "200px", "0px", "0px", "900px"],
["right", "200px", "0px", "500px", "20px"],
] as [
MultiSelectProps["listPlacement"],
string,
Expand Down
2 changes: 1 addition & 1 deletion src/components/select/multi-select/multi-select.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ describe("MultiSelect", () => {
});
});

it.each(["top", "bottom", "right", "left"])(
it.each(["top", "bottom"])(
"the listPlacement prop should be passed",
(listPlacement) => {
const wrapper = renderSelect({ listPlacement });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,23 +34,7 @@ export default {
"data-element": { table: { disable: true }, control: false },
"data-role": { table: { disable: true }, control: false },
listPlacement: {
options: [
"auto",
"auto-start",
"auto-end",
"top",
"top-start",
"top-end",
"bottom",
"bottom-start",
"bottom-end",
"right",
"right-start",
"right-end",
"left",
"left-start",
"left-end",
],
options: ["bottom", "top"],
control: {
type: "select",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export interface SimpleSelectProps
/** Maximum list height - defaults to 180 */
listMaxHeight?: number;
/** Placement of the select list in relation to the input element */
listPlacement?: Side;
listPlacement?: "top" | "bottom";
/** Use the opposite list placement if the set placement does not fit */
flipEnabled?: boolean;
/** Set this prop to enable a virtualised list of options. If it is not used then all options will be in the
Expand Down
14 changes: 0 additions & 14 deletions src/components/select/simple-select/simple-select.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,6 @@ test.describe("SimpleSelect component", () => {
([
["top", "300px", "0px", "200px", "20px"],
["bottom", "0px", "0px", "0px", "20px"],
["left", "200px", "0px", "500px", "20px"],
["right", "200px", "0px", "0px", "500px"],
] as const).forEach(([position, top, bottom, left, right]) => {
test(`should render list in ${position} position when margins are top ${top}, bottom ${bottom}, left ${left} and right ${right}`, async ({
mount,
Expand Down Expand Up @@ -959,8 +957,6 @@ test.describe("SimpleSelect component", () => {
([
["top", "0px", "0px", "0px", "20px"],
["bottom", "600px", "0px", "0px", "20px"],
["left", "200px", "0px", "0px", "900px"],
["right", "200px", "0px", "500px", "20px"],
] as [
SimpleSelectProps["listPlacement"],
string,
Expand Down Expand Up @@ -990,12 +986,6 @@ test.describe("SimpleSelect component", () => {
if (position === "bottom") {
flipPosition = "top";
}
if (position === "left") {
flipPosition = "right";
}
if (position === "right") {
flipPosition = "left";
}
await selectText(page).click();
const listElement = selectListPosition(page);
await expect(listElement).toHaveAttribute(
Expand Down Expand Up @@ -1784,8 +1774,6 @@ test.describe("Accessibility tests for SimpleSelect component", () => {
([
["top", "300px", "0px", "200px", "20px"],
["bottom", "0px", "0px", "0px", "20px"],
["left", "200px", "0px", "500px", "20px"],
["right", "200px", "0px", "0px", "500px"],
] as [
SimpleSelectProps["listPlacement"],
string,
Expand Down Expand Up @@ -1815,8 +1803,6 @@ test.describe("Accessibility tests for SimpleSelect component", () => {
([
["top", "0px", "0px", "0px", "20px"],
["bottom", "600px", "0px", "0px", "20px"],
["left", "200px", "0px", "0px", "900px"],
["right", "200px", "0px", "500px", "20px"],
] as [
SimpleSelectProps["listPlacement"],
string,
Expand Down
2 changes: 1 addition & 1 deletion src/components/select/simple-select/simple-select.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ describe("SimpleSelect", () => {
});
});

it.each(["top", "bottom", "right", "left"])(
it.each(["top", "bottom"])(
"the listPlacement prop should be passed",
(listPlacement) => {
const wrapper = renderSelect({ listPlacement });
Expand Down

0 comments on commit 28670f6

Please sign in to comment.