Fix share link focus on click

Clicking on the link share must focus and select it
This commit is contained in:
Vincent Petry 2015-10-26 12:49:52 +01:00
parent 7e3b4754f6
commit c64fb46fbf
2 changed files with 26 additions and 2 deletions

View File

@ -151,8 +151,9 @@
},
onLinkTextClick: function() {
this.focus();
this.select();
var $el = this.$el.find('.linkText');
$el.focus();
$el.select();
},
onShowPasswordClick: function() {

View File

@ -237,6 +237,29 @@ describe('OC.Share.ShareDialogView', function() {
expect(dialog.$el.find('.linkCheckbox').prop('checked')).toEqual(true);
expect(dialog.$el.find('.linkText').val()).toEqual(link);
});
it('autofocus link text when clicked', function() {
$('#allowShareWithLink').val('yes');
dialog.render();
// Toggle linkshare
dialog.$el.find('.linkCheckbox').click();
fakeServer.requests[0].respond(
200,
{ 'Content-Type': 'application/json' },
JSON.stringify({data: {token: 'xyz'}, status: 'success'})
);
var focusStub = sinon.stub($.fn, 'focus');
var selectStub = sinon.stub($.fn, 'select');
dialog.$el.find('.linkText').click();
expect(focusStub.calledOnce).toEqual(true);
expect(selectStub.calledOnce).toEqual(true);
focusStub.restore();
selectStub.restore();
});
describe('password', function() {
var slideToggleStub;