From 125d09588b9a83697a63d8beb78da6a15e6b5cf0 Mon Sep 17 00:00:00 2001 From: buddh4 Date: Mon, 23 Mar 2020 17:55:13 +0100 Subject: [PATCH] Fix #3942: Show password icon not placed correctly if field was initially hidden --- protected/humhub/docs/CHANGELOG.md | 1 + static/js/humhub/humhub.ui.form.elements.js | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/protected/humhub/docs/CHANGELOG.md b/protected/humhub/docs/CHANGELOG.md index 32f203b826..0cd7f42e84 100644 --- a/protected/humhub/docs/CHANGELOG.md +++ b/protected/humhub/docs/CHANGELOG.md @@ -9,6 +9,7 @@ HumHub Change Log - Fix #3914: Directory link in space chooser still visible when directory module not active - Fix #3915: Removed default border from canvas style - Fix #3885: Prevent comments on archived content +- Fix #3942: Show password icon not placed correctly if field was initially hidden 1.4.3 (March 4, 2020) --------------------- diff --git a/static/js/humhub/humhub.ui.form.elements.js b/static/js/humhub/humhub.ui.form.elements.js index a92918af95..e7ad1c7b26 100644 --- a/static/js/humhub/humhub.ui.form.elements.js +++ b/static/js/humhub/humhub.ui.form.elements.js @@ -14,9 +14,21 @@ humhub.module('ui.form.elements', function (module, require, $) { }); additions.register('password', '[type="password"]', function ($match) { + $match.each(function () { var $input = $(this); var $formGroup = $input.parent('.form-group'); + var invisibleTop = 0; + + /** + * We can't calculate top if input is invisible, + * Note, this may not work for more complex cases. + */ + if(!$input.is(':visible')) { + if($input.siblings('label').length) { + invisibleTop = '23px'; + } + } if($formGroup.length) { $formGroup.css('position', 'relative'); @@ -35,7 +47,7 @@ humhub.module('ui.form.elements', function (module, require, $) { 'padding': '4px', 'font-size': '19px', 'cursor': 'pointer', - 'top': $input.position().top + 'top': !$input.is(':visible') ? invisibleTop : $input.position().top }); $formGroup.prepend($pwShow); @@ -127,7 +139,7 @@ humhub.module('ui.form.elements', function (module, require, $) { }; var timeZoneSelected = function(evt) { - $toggleButton = evt.$trigger.parent().siblings('.timeZoneToggle:first'); + var $toggleButton = evt.$trigger.parent().siblings('.timeZoneToggle:first'); $toggleButton.text(evt.$trigger.find('option:selected').text()); evt.$trigger.parent().hide(); };