-
-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic dropdown react #135
Comments
Make a demo on codepen so I can have a look. |
Hey there please try to use the latest version from github and confirm if this works now. I found nesting didn't work properly and fixed it for both V3 and V4. Thanks |
Hey there, I updated the version I'm using with the latest from github, but still cant get it to work. :( The problem occurs only if I dynamically add a nested dropdown! I think that if you use any lib you'll be able to reproduce the problem. In any case I can still post a similar version on CodePen! |
The nesting works as far as I am concerned with the last BSN version, I think the problem is here: It stores an array of items instead of a LIVE HTMLCollection and thus a parent dropdown cannot count newly added and initialized child dropdown items. I am open to any code suggestion you might have. |
I can't tell much about the BSN core but isn't there a way for me to call the new Dropdown method for an element and BSN recursively check the children elements to recreate the hierarchic tree? I mean, by that, I could always add/remove items to the parent menu and request BSN to recreate the dropdown tree in order to make hierarchy work again. I'm not sure if that's how BSN works but afaik, for the current scenario, this would be an option. I'm also open to any code change you request me to do, so we could debug it together if it interests BSN at all. Do you suggest another structure to compose the Menu or doing that wouldn't make any difference at all at this point? :-) |
No there isn't. For this kind of purpose you need to work on a fork to do your specific stuff. |
I'll look into this and provide a workaround ok? |
@armandofreire check this out and let me know if this works for you. |
Changes are now committed to GH. |
@thednp thank you so much for giving it a special attention! 😄 Well, the codepen seems to work fine and as expected: the dynamic submenus are not closing unless if I click their children! Awesome work! But, I wasn't really able to understand what happened to that code: did you change anything to the code I sent before or the fix was made to the lib itself at the beginning of the pen? Oh, and one more question: does it support additional submenus of submenus (like that hierarchic menu I mentioned before)? Anyway, thanks again! ❤️ |
I pasted the entire BSN code to the JS textarea, the codebase updated to GH some minutes ago.
It should go endlessly. |
Nice! Is it going to generate a new version? Like 2.0.12 or you're going to wait for another fix to release a new build? :-) |
I don't find this improvement to be crucial to the majority of the users, I will wait another week or so, perhaps more issues/improvements pop, I just released 2.0.11 yesterday. The version will be indeed 2.0.12, as I also updated the package.json. |
Hi guys,
I'm developing an app with a Menu that renders a list of items and these items are also dropdowns. Like an hierarchic dropdown which goes opening ahead until the user finds the option he wants.
I'm currently using react for that and after the
[].map
, when I render the siblings, I try to apply them thenew Dropdown(el, { persist : true })
, which will make them a persistable dropdown. But whenever I use it with the array resultant of my GET request, I can't make the Dropdown to work! However if I simply place the subitem component on the render method, it does work. I'll try to explain better below:Things to point:
myArr
is the result of aGET
and it is triggered when I click the Menu (root) button. It changes the state of my component saving theGET
result (which triggers a render by React's default lifecycle);new Dropdown
method on both render methods (parent menu and its siblings), and even tried timeout functions and stuff, but no success;GET
, it causes the parent to lose it's references to it's siblings that's why the child does toggle the "open" class, but once they're not synced to its parent, it causes the menu to close;Could anyone help me please? :-)
The text was updated successfully, but these errors were encountered: