Comments (9)
Yeah it gets messy with an HOC.
Looking at your PR, and this discussion, I think the interface should be like this:
- Introduce a new property at the node level - say
disabled
? - If a node is
disabled
, disable the checkbox and emitdisabled
classname.
This has the following benefits:
- Keeps it generic enough for single root and multi root trees.
- Allows you to have greater flexibility in disabling nodes (goes beyond levels).
- Emitting the class lets you customize the presentational aspect - one can choose to hide or show differently based on their specific business needs.
Thoughts?
from react-dropdown-tree-select.
That's an interesting use case.
On one hand, I think it'd be nice to have a node level prop that disables the node (and may be its children too? I'm thinking similar to node.checked
...). On the other hand, I'd like to keep the core plugin simple and light.
Would you mind sharing some further details about how you plan to implement this (HOC and/or natively)?
from react-dropdown-tree-select.
Our needs is to disable selection for specific level. For example, it's not possible to select first and second level.
With a HOC, I think I can use onChange
event to catch selection and stop propagation or revert the change (I have watch yet if you fire event before or after change)
Natively, it could be more powerful cause we can remove checkbox for those levels and not firing the onChange
event at all.
I start dev on our project (with a HOC), keep me inform if you want me to include this in the lib.
from react-dropdown-tree-select.
I tried with an HOC, I can prevent tag creation and revert the click for the selected level but not for it's children :/
One solution may be to add more events to native component (onPreChange for ex)
Otherwise if you want to handle it natively, I pushed you a small PR (#50 )
from react-dropdown-tree-select.
You're welcome to take a stab at it (your PR is close enough already) or else I can get to it in few days.
from react-dropdown-tree-select.
Ok, I will work on it soon.
from react-dropdown-tree-select.
I've been using some pretty hacky CSS child selectors to achieve something similar by setting pointer-events: none
on labels and display:none
on checkboxes. Looking forward to an 'official' disabled class :)
from react-dropdown-tree-select.
You can check progress on #50
from react-dropdown-tree-select.
This is available with v1.4.0
from react-dropdown-tree-select.
Related Issues (20)
- is there a way to select/deselect option programmatically? HOT 1
- Unable to serve the cloned repository on local host so as to make changes
- React useState error
- The searchTerm in the searchPredicate function is never an empty string HOT 7
- Expand to selected item
- rtl support HOT 2
- By default the last child is focused and checked HOT 2
- SetState is not working on react-dropdown-tree-select HOT 2
- Issue when click item in long scrollable list HOT 3
- react-dropdown-tree-select - Get all selected values HOT 3
- Render calls reset the search filter on the list HOT 12
- ADA incompatibility HOT 1
- useState is not getting updated HOT 1
- I'm having the same problem where useState isn't working and if I use it, the checkbox values disappear. HOT 1
- Clicking on label for radioSelect doesn't select a node HOT 2
- Nodes expanded state are not updated when search HOT 1
- Close the selection menu HOT 1
- How can I remove the tags that appear when a node is selected in the dropdown? HOT 2
- Parent node displayed as checked despite receiving checked: false
- custom renderer for label
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-dropdown-tree-select.