Commit 5e15d741 authored by Robert Knight's avatar Robert Knight

Auto-expand direct linked annotations

When direct-linking to an annotation or a reply to one, auto-expand the
annotation thread to make it easier for the user to follow the whole
conversation around it.
parent 05e61d95
...@@ -44,7 +44,7 @@ function initialState(settings) { ...@@ -44,7 +44,7 @@ function initialState(settings) {
// present in the map, the default state is used which depends on whether // present in the map, the default state is used which depends on whether
// the annotation is a top-level annotation or a reply, whether it is // the annotation is a top-level annotation or a reply, whether it is
// selected and whether it matches the current filter. // selected and whether it matches the current filter.
expanded: {}, expanded: initialSelection(settings) || {},
// Set of IDs of annotations that have been explicitly shown // Set of IDs of annotations that have been explicitly shown
// by the user even if they do not match the current search filter // by the user even if they do not match the current search filter
......
...@@ -16,6 +16,7 @@ describe('annotationUI', function () { ...@@ -16,6 +16,7 @@ describe('annotationUI', function () {
describe('initialization', function () { describe('initialization', function () {
it('does not set a selection when settings.annotations is null', function () { it('does not set a selection when settings.annotations is null', function () {
assert.isFalse(annotationUI.hasSelectedAnnotations()); assert.isFalse(annotationUI.hasSelectedAnnotations());
assert.equal(Object.keys(annotationUI.getState().expanded).length, 0);
}); });
it('sets the selection when settings.annotations is set', function () { it('sets the selection when settings.annotations is set', function () {
...@@ -24,6 +25,13 @@ describe('annotationUI', function () { ...@@ -24,6 +25,13 @@ describe('annotationUI', function () {
testid: true, testid: true,
}); });
}); });
it('expands the selected annotations when settings.annotations is set', function () {
annotationUI = annotationUIFactory({annotations: 'testid'});
assert.deepEqual(annotationUI.getState().expanded, {
testid: true,
});
});
}); });
describe('#addAnnotations()', function () { describe('#addAnnotations()', function () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment