Commit 415b032b authored by Fatih Acet's avatar Fatih Acet Committed by Jacob Schatz

Prevent default disabled buttons and links.

parent 93a496d2
......@@ -77,6 +77,7 @@ v 8.9.0 (unreleased)
- RepositoryCheck::SingleRepositoryWorker public and private methods are now instrumented
- Improve issuables APIs performance when accessing notes !4471
- External links now open in a new tab
- Prevent default actions of disabled buttons and links
- Markdown editor now correctly resets the input value on edit cancellation !4175
- Toggling a task list item in a issue/mr description does not creates a Todo for mentions
- Improved UX of date pickers on issue & milestone forms
......
......@@ -125,6 +125,7 @@ window.onload = ->
setTimeout shiftWindow, 100
$ ->
gl.utils.preventDisabledButtons()
bootstrapBreakpoint = bp.getBreakpointSize()
$(".nicescroll").niceScroll(cursoropacitymax: '0.4', cursorcolor: '#FFF', cursorborder: "1px solid #FFF")
......
......@@ -32,5 +32,12 @@
.attr 'title', newTitle
.tooltip 'fixTitle'
gl.utils.preventDisabledButtons = ->
$('.btn').click (e) ->
if $(this).hasClass 'disabled'
e.preventDefault()
e.stopImmediatePropagation()
return false
) window
#= require lib/common_utils
describe 'Application', ->
describe 'disable buttons', ->
fixture.preload('application.html')
beforeEach ->
fixture.load('application.html')
it 'should prevent default action for disabled buttons', ->
gl.utils.preventDisabledButtons()
isClicked = false
$button = $ '#test-button'
$button.click -> isClicked = true
$button.trigger 'click'
expect(isClicked).toBe false
it 'should be on the same page if a disabled link clicked', ->
locationBeforeLinkClick = window.location.href
gl.utils.preventDisabledButtons()
$('#test-link').click()
expect(window.location.href).toBe locationBeforeLinkClick
%a#test-link.btn.disabled{:href => "/foo"} Test link
%button#test-button.btn.disabled Test Button
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