Skip to content

Commit

Permalink
Add demo for disabling multi selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskerr committed Jan 3, 2023
1 parent 89ea7e8 commit 3d26c86
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

1. Clone the repo
2. From the root, run yarn start
3. Visit localhost:3000

# Publishing a Release

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function DefaultContainer() {
}
return;
}
if (e.key === "a" && e.metaKey) {
if (e.key === "a" && e.metaKey && !tree.props.disableMultiSelection) {
e.preventDefault();
tree.selectAll();
return;
Expand Down
12 changes: 12 additions & 0 deletions packages/showcase/pages/cities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function Cities() {
const [searchTerm, setSearchTerm] = useState("");
const [count, setCount] = useState(0);
const [followsFocus, setFollowsFocus] = useState(false);
const [disableMulti, setDisableMulti] = useState(false);

useEffect(() => {
setCount(tree?.visibleNodes.length ?? 0);
Expand All @@ -35,6 +36,7 @@ export default function Cities() {
{...dimens}
initialData={data}
selectionFollowsFocus={followsFocus}
disableMultiSelection={disableMulti}
ref={(t) => setTree(t)}
openByDefault={true}
searchTerm={searchTerm}
Expand Down Expand Up @@ -100,6 +102,16 @@ export default function Cities() {
onChange={(e) => setFollowsFocus((v) => !v)}
/>
</section>
<section>
<label>
Demo the <i>disableMultiSelection</i> prop:
</label>
<input
type="checkbox"
checked={disableMulti}
onChange={(e) => setDisableMulti((v) => !v)}
/>
</section>
<section>
<label>
Demo the <i>tree</i> ref:
Expand Down

0 comments on commit 3d26c86

Please sign in to comment.