Ensure list visibility changes get counted as list changes
Fixes https://github.com/vector-im/riot-web/issues/14799 We were checking to see if the tags were visible at render time, but we needed to ensure that they were(n't) included when checking for diffs. This introduces a new kind of object cloning for semantic reasons. This also fixes the selection indicator being a bit off on custom tags.
This commit is contained in:
parent
e953bfbf88
commit
5b15d12865
3 changed files with 28 additions and 6 deletions
|
@ -36,6 +36,23 @@ export function objectExcluding(a: any, props: string[]): any {
|
|||
}, {});
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a new object which represents the provided object, with only some properties
|
||||
* included.
|
||||
* @param a The object to clone properties of. Must be defined.
|
||||
* @param props The property names to keep.
|
||||
* @returns The new object with only the provided properties.
|
||||
*/
|
||||
export function objectWithOnly(a: any, props: string[]): any {
|
||||
const existingProps = Object.keys(a);
|
||||
const diff = arrayDiff(existingProps, props);
|
||||
if (diff.removed.length === 0) {
|
||||
return objectShallowClone(a);
|
||||
} else {
|
||||
return objectExcluding(a, diff.removed);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones an object to a caller-controlled depth. When a propertyCloner is supplied, the
|
||||
* object's properties will be passed through it with the return value used as the new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue