Sorted out using <details> element, got ancestor clicks closing out to their level

This commit is contained in:
Frank Johnson
2021-09-12 17:13:30 -04:00
parent 69c83d33b1
commit 2ec3a0b202
9 changed files with 313 additions and 165 deletions

View File

@@ -244,11 +244,27 @@ const reducer = (state: State, { type, payload }): State => {
state.sideTray.length &&
state.sideTray.length === payload.length &&
state.sideTray.every((original, index) => original === payload[index])
const payloadInOriginal =
payload.length && state.sideTray.indexOf(payload[0])
const isAncestorClick =
state.sideTray.length &&
state.sideTray.length > payload.length &&
payloadInOriginal >= 0 &&
payload.every(
(incoming, i) => incoming === state.sideTray[i + payloadInOriginal]
)
if (isReClick) {
return {
...state,
sideTray: state.sideTray.slice(0, -1),
}
} else if (isAncestorClick) {
return {
...state,
sideTray: state.sideTray.slice(0, payload.length * -1 - 1),
}
}
return {
...state,