diff --git a/src/components/searchbar/searchbar.ts b/src/components/searchbar/searchbar.ts index 47a83c7c07..f2e4ea4bea 100644 --- a/src/components/searchbar/searchbar.ts +++ b/src/components/searchbar/searchbar.ts @@ -238,11 +238,19 @@ export class Searchbar extends BaseInput { // Set the input padding start var inputLeft = 'calc(50% - ' + (textWidth / 2) + 'px)'; - inputEle.style.paddingLeft = inputLeft; + if (this._plt.isRTL) { + inputEle.style.paddingRight = inputLeft; + } else { + inputEle.style.paddingLeft = inputLeft; + } // Set the icon margin start var iconLeft = 'calc(50% - ' + ((textWidth / 2) + 30) + 'px)'; - iconEle.style.marginLeft = iconLeft; + if (this._plt.isRTL) { + iconEle.style.marginRight = iconLeft; + } else { + iconEle.style.marginLeft = iconLeft; + } } } @@ -257,11 +265,19 @@ export class Searchbar extends BaseInput { var cancelStyle = cancelStyleEle.style; this._isCancelVisible = showShowCancel; if (showShowCancel) { - cancelStyle.marginRight = '0'; + if (this._plt.isRTL) { + cancelStyle.marginLeft = '0'; + } else { + cancelStyle.marginRight = '0'; + } } else { var offset = cancelStyleEle.offsetWidth; if (offset > 0) { - cancelStyle.marginRight = -offset + 'px'; + if (this._plt.isRTL) { + cancelStyle.marginLeft = -offset + 'px'; + } else { + cancelStyle.marginRight = -offset + 'px'; + } } } }