Skip to content

Commit cbce5fc

Browse files
committed
ACP2E-3273: avoid using toggle / fadeIn / fadeOut as it will generate a display none and this in turn impacts the styling for recaptcha
1 parent edcd0dc commit cbce5fc

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

app/code/Magento/Checkout/view/frontend/web/template/form/element/email.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</div>
3333

3434
<!--Hidden fields -->
35-
<fieldset class="fieldset hidden-fields" data-bind="fadeVisible: isPasswordVisible">
35+
<fieldset class="fieldset hidden-fields" data-bind="dimVisible: isPasswordVisible">
3636
<div class="field">
3737
<label class="label" for="customer-password"><span data-bind="i18n: 'Password'"></span></label>
3838
<div class="control">

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/bootstrap.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ define(function (require) {
3131
datepicker: require('./datepicker'),
3232
outerClick: require('./outer_click'),
3333
fadeVisible: require('./fadeVisible'),
34+
dimVisible: require('./dimVisible'),
3435
collapsible: require('./collapsible'),
3536
staticChecked: require('./staticChecked'),
3637
simpleChecked: require('./simple-checked'),
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Copyright 2024 Adobe
3+
* All Rights Reserved.
4+
*/
5+
6+
define([
7+
'jquery',
8+
'ko'
9+
], function ($, ko) {
10+
'use strict';
11+
12+
ko.bindingHandlers.dimVisible = {
13+
/**
14+
* Initially set the element to be instantly visible/hidden depending on the value.
15+
*
16+
* @param {HTMLElement} element
17+
* @param {Function} valueAccessor
18+
*/
19+
init: function (element, valueAccessor) {
20+
let value = valueAccessor();
21+
22+
// Use "unwrapObservable" so we can handle values that may or may not be observable
23+
if (ko.unwrap(value)) {
24+
$(element).css('visibility','visible').css('height','auto');
25+
} else {
26+
$(element).css('visibility', 'hidden').css('height', '0');
27+
}
28+
},
29+
30+
/**
31+
* Whenever the value subsequently changes, slowly fade the element in or out.
32+
*
33+
* @param {HTMLElement} element
34+
* @param {Function} valueAccessor
35+
*/
36+
update: function (element, valueAccessor) {
37+
let value = valueAccessor();
38+
39+
if (ko.unwrap(value)) {
40+
$(element).css('visibility', 'visible').css('height', 'auto');
41+
} else {
42+
$(element).css('visibility', 'hidden').css('height', '0');
43+
}
44+
}
45+
};
46+
});

0 commit comments

Comments
 (0)