Git Product home page Git Product logo

Comments (6)

matuzalemsteles avatar matuzalemsteles commented on July 18, 2024

@ethib137 unfortunately there is no option other than modifying the active property of all items, another option would be to implement an API that controls the expanded states of all items similar to what we did for the TreeView it is more ergonomic than dealing with a tree, for example adding an API expandedKeys being a Set<React.Key> if you want to close all would just set the state of expandedKeys to an empty value setExpandedKeys(new Set()).

from clay.

ethib137 avatar ethib137 commented on July 18, 2024

Hey @matuzalemsteles I think you meant "no other option other than modifying the initialExpanded property of all items", right?

If so, from my testing that still won't work either. Maybe I'm doing something wrong though. I'm trying to make sure I don't mutate any objects, but maybe I'm missing something.

https://codesandbox.io/s/vertical-nav-expand-all-snbl0j?file=/src/index.js

from clay.

matuzalemsteles avatar matuzalemsteles commented on July 18, 2024

I think you meant "no other option other than modifying the initialExpanded property of all items", right?

Oh yes, I ended up typing it wrong.

If so, from my testing that still won't work either. Maybe I'm doing something wrong though. I'm trying to make sure I don't mutate any objects, but maybe I'm missing something.

Oh yeah, that won't work it doesn't follow controlled and uncontrolled state behavior it just works as initial state and the rest is controlled internally. I think that at the time when it was developed we had not thought about these use cases.

I think we can convert this to a feature request and implement this new API to facilitate this use case.

from clay.

ethib137 avatar ethib137 commented on July 18, 2024

That would be great! Thanks @matuzalemsteles !

from clay.

matuzalemsteles avatar matuzalemsteles commented on July 18, 2024

Maybe I have to implement the Collection pattern #5032 first in the VerticalNav component so we can get access to the unique keys of each item, so we could have an expandedKeys with the keys of each item as we can't infer it with the current implementation we would have to use index but this can have problems when you need to filter the items as is also your use case.

from clay.

github-actions avatar github-actions commented on July 18, 2024

This issue has been merged and will be released in DXP at https://issues.liferay.com/browse/LPS-183595

from clay.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.