-
Notifications
You must be signed in to change notification settings - Fork 22
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
Persist open state for list items during session #90
Labels
backlog
Queued in backlog
enhancement
New feature or request
spring cleaning
Could be cleaned up one day
Comments
bpmn-io-tasks
bot
added
in progress
Currently worked on
and removed
backlog
Queued in backlog
labels
Aug 6, 2021
pinussilvestrus
added
backlog
Queued in backlog
and removed
in progress
Currently worked on
labels
Aug 6, 2021
A sketch of how to use the import {
useContext,
useMemo,
useState
} from 'preact/hooks';
import {
LayoutContext
} from '../../context';
export default function CollapsibleEntry(props) {
const {
// ...
open: shouldOpen
} = props;
const {
layout,
setLayoutForKey
} = useContext(LayoutContext);
const layoutKey = useMemo(() => {
return `collapsible-${id}`;
}, [ id ]);
const collapsibleLayout = layout[layoutKey] || {};
const [ open, setOpen ] = useState(shouldOpen || collapsibleLayout.open);
const toggleOpen = () => {
setOpen(!open);
setLayoutForKey(layoutKey, {
...collapsibleLayout,
open: !open
});
};
// ...
} {
"collapsible-StartEvent_1-output-0": {
"open": true
},
"collapsible-StartEvent_1-output-1": {
"open": false
},
"collapsible-StartEvent_1-output-2": {
"open": true
},
"collapsible-Task_1-output-0": {
"open": false
},
"collapsible-StartEvent_1-output-3": {
"open": false
}
} |
Open for discussion:
|
This was referenced Aug 23, 2021
With #99 we've built a fundamental to use the layout context for individual components. Let's use that for list items (and nested list items) as well 👍 |
pinussilvestrus
added
ready
Ready to be worked on
spring cleaning
Could be cleaned up one day
and removed
backlog
Queued in backlog
labels
Oct 7, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backlog
Queued in backlog
enhancement
New feature or request
spring cleaning
Could be cleaned up one day
Is your feature request related to a problem? Please describe
This is a follow up of: #86
Introducing #86, list items are completely unique per id. Therefore they have their own state depending on what element is selected. Since the items are unique per id, they got rerendered when a new element got selected.+
That causes that the state got lost when switching from one element to another and switch back again (the item is closed, no matter it was opened after the switch).
Describe the solution you'd like
For a smoother editing experience and to avoid opening list items multiple times during element switches, it should be possible to persist the opened state per item during a session (or multiple sessions).
We have the
LayoutContext
which was meant for exactly this purpose, but we are currently not using it.Describe alternatives you've considered
propertiesPanel.layoutChanged
.Additional context
Cf. #86
The text was updated successfully, but these errors were encountered: