Commit 3a503e50 authored by Yisu Kim's avatar Yisu Kim Committed by Robert Knight

Add test for scrolling when the target is within the details tag

parent de196f60
...@@ -128,5 +128,37 @@ describe('annotator/util/scroll', () => { ...@@ -128,5 +128,37 @@ describe('annotator/util/scroll', () => {
delete document.body.tagName; delete document.body.tagName;
} }
}); });
// A test for scrolling when there is a target within the 'details' tag.
it('scrolls element into view when the target is within the details tag',async () => {
const container = document.createElement('div');
container.style.height = '500px';
container.style.overflow = 'auto';
container.style.position = 'relative';
document.body.append(container);
const details = document.createElement('details');
details.style.position = 'absolute';
details.style.top = '1000px';
container.append(details);
const summary = document.createElement('summary');
summary.append('Summary');
details.append(summary);
const target = document.createElement('div');
target.style.height = '20px';
target.style.width = '100px';
details.append(target);
await scrollElementIntoView(target, { maxDuration: 1 });
const containerRect = container.getBoundingClientRect();
const targetRect = target.getBoundingClientRect();
assert.isTrue(containerRect.top <= targetRect.top);
assert.isTrue(containerRect.bottom >= targetRect.bottom);
});
}); });
}); });
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