Commit bb8e39cf authored by Fatih Acet's avatar Fatih Acet

Merge branch 'lbennett/gitlab-ce-18120-focus-filter-shortcut' into 'master'

Added shortcut to focus filters

## What does this MR do?

Adds shortcut `f` to focus filter inputs.

## Are there points in the code the reviewer needs to double check?

Is this a valid implementation?

Please check [this comment below](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/4570#note_12359978)!

## Why was this MR needed?

Keyboard ninja UX  

## What are the relevant issue numbers?

Closes #18120.

## Screenshots (if relevant)

![Screen_Shot_2016-06-09_at_18.34.56](/uploads/d4cfb6ec340c118f5227be3f16ffbed1/Screen_Shot_2016-06-09_at_18.34.56.png)

## Does this MR meet the acceptance criteria?

- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [ ] API support added
- [ ] Tests
  - [ ] Added for this feature/bug
  - [ ] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)

See merge request !4763
parents 7458892c e0f3b66c
......@@ -261,6 +261,7 @@ v 8.9.0
- Add rake task 'gitlab:db:configure' for conditionally seeding or migrating the database
- Changed the Slack build message to use the singular duration if necessary (Aran Koning)
- Fix race condition on merge when build succeeds
- Added shortcut to focus filter search fields and added documentation #18120
- Links from a wiki page to other wiki pages should be rewritten as expected
- Add option to project to only allow merge requests to be merged if the build succeeds (Rui Santos)
- Added navigation shortcuts to the project pipelines, milestones, builds and forks page. !4393
......
......@@ -32,13 +32,11 @@ issuable_created = false
$search = $('#issue_search')
$form = $('.js-filter-form')
$input = $("input[name='#{$search.attr('name')}']", $form)
if $input.length is 0
$form.append "<input type='hidden' name='#{$search.attr('name')}' value='#{_.escape($search.val())}'/>"
else
$input.val $search.val()
Issuable.filterResults $form
Issuable.filterResults $form if $search.val() isnt ''
, 500)
initLabelFilterRemove: ->
......
......@@ -5,13 +5,12 @@
this.initPagination()
initSearch: ->
@timer = null
$(".projects-list-filter").on('keyup', ->
clearTimeout(@timer)
@timer = setTimeout(ProjectsList.filterResults, 500)
)
projectsListFilter = $('.projects-list-filter')
debounceFilter = _.debounce ProjectsList.filterResults, 500
projectsListFilter.on 'keyup', (e) ->
debounceFilter() if projectsListFilter.val() isnt ''
filterResults: =>
filterResults: ->
$('.projects-list-holder').fadeTo(250, 0.5)
form = null
......
......@@ -2,9 +2,10 @@ class @Shortcuts
constructor: (skipResetBindings) ->
@enabledHelp = []
Mousetrap.reset() if not skipResetBindings
Mousetrap.bind('?', @onToggleHelp)
Mousetrap.bind('s', Shortcuts.focusSearch)
Mousetrap.bind(['ctrl+shift+p', 'command+shift+p'], @toggleMarkdownPreview)
Mousetrap.bind '?', @onToggleHelp
Mousetrap.bind 's', Shortcuts.focusSearch
Mousetrap.bind 'f', (e) => @focusFilter e
Mousetrap.bind ['ctrl+shift+p', 'command+shift+p'], @toggleMarkdownPreview
Mousetrap.bind('t', -> Turbolinks.visit(findFileURL)) if findFileURL?
onToggleHelp: (e) =>
......@@ -32,10 +33,16 @@ class @Shortcuts
$('.js-more-help-button').remove()
)
focusFilter: (e) ->
@filterInput ?= $('input[type=search]', '.nav-controls')
@filterInput.focus()
e.preventDefault()
@focusSearch: (e) ->
$('#search').focus()
e.preventDefault()
$(document).on 'click.more_help', '.js-more-help-button', (e) ->
$(@).remove()
$('.hidden-shortcut').show()
......
......@@ -18,6 +18,10 @@
%td.shortcut
.key s
%td Focus Search
%tr
%td.shortcut
.key f
%td Focus Filter
%tr
%td.shortcut
.key ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment