Skip to content

Commit 2b09630

Browse files
authored
feat: add highlight selection to S2 TreeView (adobe#9769)
* Merge branch 'main' into tree-section * feat: add highlight selection to TreeView * clean up * fixes * update comment * add highlight selection to docs * update hcm * update chromatic * fix forced colors error * add highlight selection to docs * export isPrevSelected from ListView * add link to jsdoc * export additional functions * update focus ring * add hcm back for focus ring * prevent focus ring from getting cut off when inside selected group
1 parent 846f1e8 commit 2b09630

File tree

4 files changed

+206
-59
lines changed

4 files changed

+206
-59
lines changed

packages/@react-spectrum/s2/chromatic/TreeView.stories.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,23 @@ export const TreeStatic: StoryObj<typeof TreeExample> = {
143143
render: (args) => <TreeExample {...args} />
144144
};
145145

146-
export const TreeSelection: StoryObj<typeof TreeExample> = {
146+
export const TreeCheckboxSelection: StoryObj<typeof TreeExample> = {
147147
...TreeStatic,
148148
args: {
149149
selectionMode: 'multiple',
150150
defaultSelectedKeys: ['projects-2', 'projects-3']
151151
}
152152
};
153153

154+
export const TreeHighlightSelection: StoryObj<typeof TreeExample> = {
155+
...TreeStatic,
156+
args: {
157+
selectionMode: 'multiple',
158+
selectionStyle: 'highlight',
159+
defaultSelectedKeys: ['projects-2', 'projects-3']
160+
}
161+
};
162+
154163
export const TreeDisableSelection: StoryObj<typeof TreeExample> = {
155164
...TreeStatic,
156165
args: {

packages/@react-spectrum/s2/src/ListView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,15 +716,15 @@ function isNextSelected(id: Key | undefined, state: ListState<unknown>) {
716716
let keyAfter = state.collection.getKeyAfter(id);
717717
return keyAfter != null && state.selectionManager.isSelected(keyAfter);
718718
}
719-
function isPrevSelected(id: Key | undefined, state: ListState<unknown>) {
719+
export function isPrevSelected(id: Key | undefined, state: ListState<unknown>) {
720720
if (id == null || !state) {
721721
return false;
722722
}
723723
let keyBefore = state.collection.getKeyBefore(id);
724724
return keyBefore != null && state.selectionManager.isSelected(keyBefore);
725725
}
726726

727-
function isFirstItem(id: Key | undefined, state: ListState<unknown>) {
727+
export function isFirstItem(id: Key | undefined, state: ListState<unknown>) {
728728
if (id == null || !state) {
729729
return false;
730730
}

0 commit comments

Comments
 (0)