Skip to content

Commit

Permalink
Merge branch 'next' into renovate/mui-core
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Fauquette <[email protected]>
  • Loading branch information
alexfauquette authored Mar 19, 2024
2 parents 68de06d + 22c774e commit 8fd450c
Show file tree
Hide file tree
Showing 18 changed files with 831 additions and 858 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/no-response.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ on:
issue_comment:
types: [created]
schedule:
# Schedule for five minutes after the hour, every hour
- cron: '5 * * * *'
# These runs in our repos are spread evenly throughout the day to avoid hitting rate limits.
# If you change this schedule, consider changing the remaining repositories as well.
# Runs at 3 am, 3 pm
- cron: '0 3,15 * * *'

permissions: {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,38 @@ you can use the new `onItemSelectionToggle` prop which is called whenever an ite

:::

### Focus the Tree Item instead of the Tree View

The focus is now applied to the Tree Item root element instead of the Tree View root element.

This change will allow new features that require the focus to be on the Tree Item,
like the drag and drop reordering of items.
It also solves several issues with focus management,
like the inability to scroll to the focused item when a lot of items are rendered.

This will mostly impact how you write tests to interact with the Tree View:

For example, if you were writing a test with `react-testing-library`, here is what the changes could look like:

```diff
it('test example on first item', () => {
const { getByRole } = render(
<SimpleTreeView>
<TreeItem itemId="one">One</TreeItem>
<TreeItem itemId="two">Two</TreeItem>
</SimpleTreeView>
);
- const tree = getByRole('tree');
+ const treeItem = getByRole('treeitem', { name: 'One' });
act(() => {
- tree.focus();
+ treeItem.focus();
});
- fireEvent.keyDown(tree, { key: 'ArrowDown' });
+ fireEvent.keyDown(treeItem, { key: 'ArrowDown' });
})
```

### ✅ Use `useTreeItemState` instead of `useTreeItem`

The `useTreeItem` hook has been renamed `useTreeItemState`.
Expand Down
Loading

0 comments on commit 8fd450c

Please sign in to comment.