Skip to content

Commit 1789408

Browse files
committed
fix: respect canRename property in item payload
1 parent bbdbfe4 commit 1789408

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

next-release-notes.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
### Breaking Changes
22
- Changed the behavior for dropping an item at the bottom of an open folder has changed, and will now drop
33
into the open folder at its top, instead of the parent folder below the open folder. See discussion at #148 for details.
4-
You can opt out of this behavior by setting the `canDropBelowOpenFolders` prop on the tree environment (#148).
4+
You can opt out of this behavior by setting the `canDropBelowOpenFolders` prop on the tree environment (#148).
5+
6+
### Bug Fixes
7+
- Fixed a bug where the `canRename` property in a tree item payload was not respected.

packages/core/src/tree/useTreeKeyboardBindings.ts

+12-5
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,19 @@ export const useTreeKeyboardBindings = () => {
170170
useHotkey(
171171
'renameItem',
172172
e => {
173-
if (viewState.focusedItem !== undefined) {
174-
e.preventDefault();
175-
const item = environment.items[viewState.focusedItem];
176-
environment.onStartRenamingItem?.(item, treeId);
177-
setRenamingItem(item.index);
173+
if (viewState.focusedItem === undefined) {
174+
return;
175+
}
176+
177+
e.preventDefault();
178+
const item = environment.items[viewState.focusedItem];
179+
180+
if (item.canRename === false) {
181+
return;
178182
}
183+
184+
environment.onStartRenamingItem?.(item, treeId);
185+
setRenamingItem(item.index);
179186
},
180187
isActiveTree && (environment.canRename ?? true) && !isRenaming
181188
);

0 commit comments

Comments
 (0)