Skip to content

Commit 0e9b169

Browse files
committed
Handle textareas being initialized after initial page load.
1 parent bf975b4 commit 0e9b169

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

browser-extension/src/lib/registries.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export class EnhancerRegistry {
6969
this.preparedEnhancers.add(enhancer)
7070
}
7171
const overtype = enhancer.enhance(textarea, spot)
72+
this.handleDelayedValueInjection(overtype)
7273
return { enhancer, overtype, spot, textarea }
7374
}
7475
} catch (error) {
@@ -78,6 +79,24 @@ export class EnhancerRegistry {
7879
return null
7980
}
8081

82+
private handleDelayedValueInjection(overtype: OverTypeInstance): void {
83+
// GitHub sometimes injects textarea content after a delay
84+
// We need to trigger OverType to update its preview after such injections
85+
// https://github.com/diffplug/gitcasso/issues/46
86+
setTimeout(() => {
87+
overtype.updatePreview()
88+
}, 100)
89+
setTimeout(() => {
90+
overtype.updatePreview()
91+
}, 200)
92+
setTimeout(() => {
93+
overtype.updatePreview()
94+
}, 400)
95+
setTimeout(() => {
96+
overtype.updatePreview()
97+
}, 8000)
98+
}
99+
81100
getEnhancerCount(): number {
82101
return this.enhancers.size
83102
}

0 commit comments

Comments
 (0)