Skip to content

Commit

Permalink
fix(ui): expand tab key presses to 2 spaces in the Flux editor
Browse files Browse the repository at this point in the history
  • Loading branch information
chnn committed May 6, 2019
1 parent bc80113 commit 137a3b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

### Bug Fixes
1. [13753](https://github.com/influxdata/influxdb/pull/13753): Removed hardcoded bucket for Getting Started with Flux dashboard
1. [13797](https://github.com/influxdata/influxdb/pull/13797): Expand tab key presses to 2 spaces in the Flux editor

### UI Improvements

Expand Down
2 changes: 2 additions & 0 deletions ui/src/shared/components/FluxEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {EXCLUDED_KEYS} from 'src/shared/constants/fluxEditor'

// Utils
import {getSuggestions} from 'src/shared/utils/autoComplete'
import {onTab} from 'src/shared/utils/fluxEditor'

// Types
import {OnChangeScript, Suggestion} from 'src/types/flux'
Expand Down Expand Up @@ -96,6 +97,7 @@ class FluxEditor extends PureComponent<Props, State> {
theme: 'time-machine',
completeSingle: false,
gutters: ['error-gutter'],
extraKeys: {Tab: onTab},
}

return (
Expand Down
9 changes: 9 additions & 0 deletions ui/src/shared/utils/fluxEditor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Doc} from 'codemirror'

export const onTab = (cm: Doc & {indentSelection: (a: any) => any}) => {
if (cm.somethingSelected()) {
cm.indentSelection('add')
} else {
cm.replaceSelection(' ', 'end')
}
}

0 comments on commit 137a3b9

Please sign in to comment.