Remove IntersectionObserver in ResultsView
MODIFY
lib/project/results-view.js
lib/project/results-view.js
@@ -26,12 +26,6 @@ class ResultsView {
etch.initialize(this);
- const visibilityChangedObserver = new IntersectionObserver(() => {
- this.invalidateItemHeights()
- visibilityChangedObserver.disconnect()
- });
- visibilityChangedObserver.observe(this.element);
-
resizeDetector({strategy: 'scroll'}).listenTo(this.element, this.invalidateItemHeights.bind(this));
this.element.addEventListener('mousedown', this.handleClick.bind(this));
@@ -358,7 +352,6 @@ class ResultsView {
collapseResult() {
if (this.selectedResultIndex !== -1) {
this.collapsedResultIndices[this.selectedResultIndex] = true;
- this.selectedMatchIndex = -1;
etch.update(this);
}
}

MODIFY
spec/project-find-view-spec.js
spec/project-find-view-spec.js
@@ -22,6 +22,10 @@ describe('ProjectFindView', () => {
function getExistingResultsPane() {
const pane = atom.workspace.paneForURI(ResultsPaneView.URI);
if (pane) {
+
+ // Allow element-resize-detector to perform batched measurements
+ advanceClock(1);
+
return pane.itemForURI(ResultsPaneView.URI);
}
}
@@ -409,9 +413,7 @@ describe('ProjectFindView', () => {
const resultsPaneView2 = atom.views.getView(pane2.itemForURI(ResultsPaneView.URI));
expect(pane1).not.toBe(pane2);
expect(resultsPaneView1).not.toBe(resultsPaneView2);
-
- await resultsView1.heightInvalidationPromise
- await resultsView2.heightInvalidationPromise
+ simulateResizeEvent(resultsView2.element);
const {length: resultCount} = resultsPaneView1.querySelectorAll('.search-result');
expect(resultCount).toBeGreaterThan(0);
@@ -437,9 +439,8 @@ describe('ProjectFindView', () => {
expect(pane1).not.toBe(pane2);
expect(resultsPaneView1).not.toBe(resultsPaneView2);
- resultsPaneView2.style.height = '420px'
- await resultsView1.heightInvalidationPromise
- await resultsView2.heightInvalidationPromise
+ resultsPaneView2.style.height = '420px';
+ simulateResizeEvent(resultsView2.element);
const {length: resultCount} = resultsPaneView1.querySelectorAll('.search-result');
expect(resultCount).toBeGreaterThan(0);
@@ -1508,3 +1509,10 @@ describe('ProjectFindView', () => {
});
});
});
+
+function simulateResizeEvent(element) {
+ Array.from(element.children).forEach((child) => {
+ child.dispatchEvent(new AnimationEvent('animationstart'));
+ });
+ advanceClock(1);
+}
\ No newline at end of file

MODIFY
spec/results-view-spec.js
spec/results-view-spec.js
@@ -22,6 +22,10 @@ describe('ResultsView', () => {
function getResultsPane() {
let pane = atom.workspace.paneForURI(ResultsPaneView.URI);
+
+ // Allow element-resize-detector to perform batched measurements
+ advanceClock(1);
+
if (pane) return pane.itemForURI(ResultsPaneView.URI);
}

Remove IntersectionObserver in ResultsView