You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
File selection of disabled entries possible with space #5934
bugConfirmed bugs or reports that are very likely to be bugshelp wantedIssues marked as ideal for external contributorspriority-3Bugs that affect small number of users and/or relatively cosmetic in nature
I have a long-running pre-commit hook. After hitting commit, the checkboxes for file selection are getting disabled immediately and any clicking on these checkboxes are prevented (everything fine here).
However, I can still mark a checkbox by hitting space on a highlighted entry/file, which is quite misleading. Luckily, this has no impact on the commit itself (nor the pre-commit hook), so it's only a bug in convenience which might be confusing for users, but without any impact on functionality.
Version
GitHub Desktop: 1.4.2
Operating system: Microsoft Windows [Version 10.0.17134.345]
Steps to Reproduce
Add a long-running pre-commit hook; for testing, try sleep 30s
Edit some files (at least 2)
Select one file and commit it
While the pre-commit hook runs, select the other file and hit space. You can also deselect the currently committed file
Expected Behavior
Hitting space doesn't do anything until the commit has been done.
Actual Behavior
Hitting space selects/deselects files, although they're disabled.
However, I can still mark a checkbox by hitting space on a highlighted entry/file, which is quite misleading.
Yep, that's definitely a minor UX bug we should address. I think the Enter key also has the same issue.
I put together a rough patch to address this below, for someone to take further:
diff --git a/app/src/ui/changes/changes-list.tsx b/app/src/ui/changes/changes-list.tsx
index df84b8514..b188e8df3 100644
--- a/app/src/ui/changes/changes-list.tsx+++ b/app/src/ui/changes/changes-list.tsx@@ -368,6 +368,18 @@ export class ChangesList extends React.Component<
showContextualMenu(items)
}
+ private onRowKeyDown = (row: number, event: React.KeyboardEvent<any>) => {+ if (!this.props.isCommitting) {+ return+ }++ // the commit is already in-flight, but this check prevents the+ // user from changing selection and expecting it to work+ if (event.key === 'Enter' || event.key === ' ') {+ event.preventDefault()+ }+ }+
public render() {
const fileList = this.props.workingDirectory.files
const fileCount = fileList.length
@@ -401,6 +413,7 @@ export class ChangesList extends React.Component<
onSelectionChanged={this.props.onFileSelectionChanged}
invalidationProps={this.props.workingDirectory}
onRowClick={this.props.onRowClick}
+ onRowKeyDown={this.onRowKeyDown}
/>
<CommitMessage
diff --git a/app/src/ui/lib/list/list.tsx b/app/src/ui/lib/list/list.tsx
index e534ebfd7..c3c07b659 100644
--- a/app/src/ui/lib/list/list.tsx+++ b/app/src/ui/lib/list/list.tsx@@ -413,6 +413,11 @@ export class List extends React.Component<IListProps, IListState> {
}
private onKeyDown = (event: React.KeyboardEvent<any>) => {
+ // onRowKeyDown previously flagged this event to be prevented+ if (event.defaultPrevented) {+ return+ }+
if (event.key === 'Enter' || event.key === ' ') {
this.toggleSelection(event)
event.preventDefault()
The change required in list.tsx I believe is related to how DOM events propagate, but I haven't researched it deeply and want to ensure it doesn't break other functionality.
If you want to test a long-running commit without setting a pre-commit hook, here's a test helper I put together that helped me with this spike:
diff --git a/app/src/lib/git/commit.ts b/app/src/lib/git/commit.ts
index 826f29ca5..ec719b0e3 100644
--- a/app/src/lib/git/commit.ts+++ b/app/src/lib/git/commit.ts@@ -4,11 +4,21 @@ import { Repository } from '../../models/repository'
import { WorkingDirectoryFileChange } from '../../models/status'
import { unstageAll } from './reset'
+function delay(ms: number): Promise<void> {+ return new Promise<void>((resolve, reject) => {+ setTimeout(() => {+ resolve()+ }, ms)+ })+}+
export async function createCommit(
repository: Repository,
message: string,
files: ReadonlyArray<WorkingDirectoryFileChange>
): Promise<boolean> {
+ await delay(30000)+
// Clear the staging area, our diffs reflect the difference between the
// working directory and the last commit (if any) so our commits should
// do the same thing.
bugConfirmed bugs or reports that are very likely to be bugshelp wantedIssues marked as ideal for external contributorspriority-3Bugs that affect small number of users and/or relatively cosmetic in nature
Activity
shiftkey commentedon Oct 18, 2018
@biolauri thanks for the report!
Yep, that's definitely a minor UX bug we should address. I think the
Enterkey also has the same issue.I put together a rough patch to address this below, for someone to take further:
The change required in
list.tsxI believe is related to how DOM events propagate, but I haven't researched it deeply and want to ensure it doesn't break other functionality.If you want to test a long-running commit without setting a pre-commit hook, here's a test helper I put together that helped me with this spike: