Skip to content
Snippets Groups Projects
Commit 415b032b authored by Fatih Acet's avatar Fatih Acet Committed by Jacob Schatz
Browse files

Prevent default disabled buttons and links.

parent 93a496d2
No related branches found
No related tags found
1 merge request!4658Prevent default disabled buttons and links.
Pipeline #
Loading
@@ -77,6 +77,7 @@ v 8.9.0 (unreleased)
Loading
@@ -77,6 +77,7 @@ v 8.9.0 (unreleased)
- RepositoryCheck::SingleRepositoryWorker public and private methods are now instrumented - RepositoryCheck::SingleRepositoryWorker public and private methods are now instrumented
- Improve issuables APIs performance when accessing notes !4471 - Improve issuables APIs performance when accessing notes !4471
- External links now open in a new tab - 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 - 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 - 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 - Improved UX of date pickers on issue & milestone forms
Loading
Loading
Loading
@@ -125,6 +125,7 @@ window.onload = ->
Loading
@@ -125,6 +125,7 @@ window.onload = ->
setTimeout shiftWindow, 100 setTimeout shiftWindow, 100
   
$ -> $ ->
gl.utils.preventDisabledButtons()
bootstrapBreakpoint = bp.getBreakpointSize() bootstrapBreakpoint = bp.getBreakpointSize()
   
$(".nicescroll").niceScroll(cursoropacitymax: '0.4', cursorcolor: '#FFF', cursorborder: "1px solid #FFF") $(".nicescroll").niceScroll(cursoropacitymax: '0.4', cursorcolor: '#FFF', cursorborder: "1px solid #FFF")
Loading
Loading
Loading
@@ -32,5 +32,12 @@
Loading
@@ -32,5 +32,12 @@
.attr 'title', newTitle .attr 'title', newTitle
.tooltip 'fixTitle' .tooltip 'fixTitle'
   
gl.utils.preventDisabledButtons = ->
$('.btn').click (e) ->
if $(this).hasClass 'disabled'
e.preventDefault()
e.stopImmediatePropagation()
return false
   
) window ) 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment