Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions lib/views/commit-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,7 @@ const TOOLTIP_DELAY = 200;

// CustomEvent is a DOM primitive, which v8 can't access
// so we're essentially lazy loading to keep snapshotting from breaking.
const getFakeKeyDownEvent = function(keyCode) {
class FakeKeyDownEvent extends CustomEvent {
constructor(kCode) {
super('keydown');
this.keyCode = kCode;
}
}
return new FakeKeyDownEvent(keyCode);
};
let FakeKeyDownEvent;

export default class CommitView extends React.Component {
static focus = {
Expand Down Expand Up @@ -83,7 +75,16 @@ export default class CommitView extends React.Component {
return;
}

const fakeEvent = getFakeKeyDownEvent(keyCode);
if (!FakeKeyDownEvent) {
FakeKeyDownEvent = class extends CustomEvent {
constructor(kCode) {
super('keydown');
this.keyCode = kCode;
}
};
}

const fakeEvent = new FakeKeyDownEvent(keyCode);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @annthurium - took the liberty to 🎨 this. Hope that's okay!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome, thank you!!

this.refCoAuthorSelect.handleKeyDown(fakeEvent);

if (!fakeEvent.defaultPrevented) {
Expand Down Expand Up @@ -205,13 +206,14 @@ export default class CommitView extends React.Component {
className="github-CommitView-button github-CommitView-commit btn btn-primary"
onClick={this.commit}
disabled={!this.commitIsEnabled()}>{this.commitButtonText()}</button>
<Tooltip
manager={this.props.tooltips}
target={() => this.refCommitButton}
className="github-CommitView-button-tooltip"
title={`${modKey}-enter to commit`}
showDelay={TOOLTIP_DELAY}
/>
{this.commitIsEnabled() &&
<Tooltip
manager={this.props.tooltips}
target={() => this.refCommitButton}
className="github-CommitView-button-tooltip"
title={`${modKey}-enter to commit`}
showDelay={TOOLTIP_DELAY}
/>}
<div className={`github-CommitView-remaining-characters ${remainingCharsClassName}`}>
{this.getRemainingCharacters()}
</div>
Expand Down