-
-
Notifications
You must be signed in to change notification settings - Fork 367
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve collection performance with multiple items (#3295)
Closes #3294
- Loading branch information
Showing
7 changed files
with
141 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
"@ariakit/core": patch | ||
"@ariakit/react-core": patch | ||
"@ariakit/react": patch | ||
--- | ||
|
||
Improved performance of large collections | ||
|
||
Components like [`MenuItem`](https://ariakit.org/reference/menu-item), [`ComboboxItem`](https://ariakit.org/reference/combobox-item), and [`SelectItem`](https://ariakit.org/reference/select-item) should now offer improved performance when rendering large collections. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,27 @@ | ||
import { version } from "react"; | ||
import { click, press, q, waitFor } from "@ariakit/test"; | ||
|
||
const is17 = version.startsWith("17"); | ||
|
||
describe.skipIf(is17)("dialog-framer-motion", () => { | ||
test("show/hide on click", async () => { | ||
expect(q.dialog()).not.toBeInTheDocument(); | ||
await click(q.button("Show modal")); | ||
expect(q.dialog()).toBeVisible(); | ||
expect(q.button("OK")).toHaveFocus(); | ||
await click(q.button("OK")); | ||
expect(q.dialog()).toBeVisible(); | ||
expect(q.button("Show modal")).toHaveFocus(); | ||
await waitFor(() => expect(q.dialog()).not.toBeInTheDocument()); | ||
expect(q.button("Show modal")).toHaveFocus(); | ||
}); | ||
test("show/hide on click", async () => { | ||
expect(q.dialog()).not.toBeInTheDocument(); | ||
await click(q.button("Show modal")); | ||
expect(q.dialog()).toBeVisible(); | ||
expect(q.button("OK")).toHaveFocus(); | ||
await click(q.button("OK")); | ||
expect(q.dialog()).toBeVisible(); | ||
expect(q.button("Show modal")).toHaveFocus(); | ||
await waitFor(() => expect(q.dialog()).not.toBeInTheDocument()); | ||
expect(q.button("Show modal")).toHaveFocus(); | ||
}); | ||
|
||
test("prevent body scroll", async () => { | ||
expect(document.body).not.toHaveStyle({ overflow: "hidden" }); | ||
await press.Tab(); | ||
await press.Enter(); | ||
expect(document.body).toHaveStyle({ overflow: "hidden" }); | ||
expect(q.dialog()).toBeVisible(); | ||
expect(document.body).toHaveStyle({ overflow: "hidden" }); | ||
await press.Enter(); | ||
expect(q.dialog()).toBeVisible(); | ||
expect(document.body).toHaveStyle({ overflow: "hidden" }); | ||
await waitFor(() => expect(q.dialog()).not.toBeInTheDocument()); | ||
expect(document.body).not.toHaveStyle({ overflow: "hidden" }); | ||
}); | ||
test("prevent body scroll", async () => { | ||
expect(document.body).not.toHaveStyle({ overflow: "hidden" }); | ||
await press.Tab(); | ||
await press.Enter(); | ||
expect(document.body).toHaveStyle({ overflow: "hidden" }); | ||
expect(q.dialog()).toBeVisible(); | ||
expect(document.body).toHaveStyle({ overflow: "hidden" }); | ||
await press.Enter(); | ||
expect(q.dialog()).toBeVisible(); | ||
expect(document.body).toHaveStyle({ overflow: "hidden" }); | ||
await waitFor(() => expect(q.dialog()).not.toBeInTheDocument()); | ||
expect(document.body).not.toHaveStyle({ overflow: "hidden" }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,56 @@ | ||
import { version } from "react"; | ||
import { click, press, q, waitFor } from "@ariakit/test"; | ||
|
||
const is17 = version.startsWith("17"); | ||
|
||
describe.skipIf(is17)("menu-framer-motion", () => { | ||
test("show/hide on click", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await click(q.button("Options")); | ||
expect(q.menu()).toBeVisible(); | ||
expect(q.menu()).toHaveFocus(); | ||
await click(q.button("Options")); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
test("show/hide on click", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await click(q.button("Options")); | ||
expect(q.menu()).toBeVisible(); | ||
expect(q.menu()).toHaveFocus(); | ||
await click(q.button("Options")); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
|
||
test("show/hide on enter", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await press.Tab(); | ||
await press.Enter(); | ||
expect(q.menu()).toBeVisible(); | ||
expect(q.menuitem("Edit")).toHaveFocus(); | ||
await press.ShiftTab(); | ||
await press.Enter(); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
test("show/hide on enter", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await press.Tab(); | ||
await press.Enter(); | ||
expect(q.menu()).toBeVisible(); | ||
expect(q.menuitem("Edit")).toHaveFocus(); | ||
await press.ShiftTab(); | ||
await press.Enter(); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
|
||
test("show/hide on space", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await press.Tab(); | ||
await press.Space(); | ||
expect(q.menu()).toBeVisible(); | ||
expect(q.menuitem("Edit")).toHaveFocus(); | ||
await press.ShiftTab(); | ||
await press.Space(); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
test("show/hide on space", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await press.Tab(); | ||
await press.Space(); | ||
expect(q.menu()).toBeVisible(); | ||
expect(q.menuitem("Edit")).toHaveFocus(); | ||
await press.ShiftTab(); | ||
await press.Space(); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
|
||
test("hide on esc", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await click(q.button("Options")); | ||
await press.Escape(); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
test("hide on esc", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await click(q.button("Options")); | ||
await press.Escape(); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
|
||
test("hide on click outside", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await click(q.button("Options")); | ||
await click(document.body); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); | ||
test("hide on click outside", async () => { | ||
expect(q.menu()).not.toBeInTheDocument(); | ||
await click(q.button("Options")); | ||
await click(document.body); | ||
expect(q.button("Options")).toHaveFocus(); | ||
expect(q.menu()).toBeVisible(); | ||
await waitFor(() => expect(q.menu()).not.toBeInTheDocument()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters