From cc8ea823d0f27d56b0876d217c5a78e33eac0fde Mon Sep 17 00:00:00 2001 From: asvarcas Date: Tue, 29 Oct 2019 23:53:08 -0300 Subject: [PATCH] Fix ResettableTextField component endAdornment prop not being applied. --- .../src/input/ResettableTextField.js | 76 +++++++++++-------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/packages/ra-ui-materialui/src/input/ResettableTextField.js b/packages/ra-ui-materialui/src/input/ResettableTextField.js index afe52b099e5..92545bc8ee9 100644 --- a/packages/ra-ui-materialui/src/input/ResettableTextField.js +++ b/packages/ra-ui-materialui/src/input/ResettableTextField.js @@ -1,4 +1,4 @@ -import React, { useState, useCallback } from 'react'; +import React, { Fragment, useState, useCallback } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import InputAdornment from '@material-ui/core/InputAdornment'; @@ -84,42 +84,54 @@ function ResettableTextField({ ...restClasses } = classes; + const { endAdornment, ...InputPropsWithoutEndAdornment } = InputProps; + return ( - - - - - ), - ...InputProps, + endAdornment: + resettable && value ? ( + + + + + + + {endAdornment} + + ) : ( + endAdornment + ), + ...InputPropsWithoutEndAdornment, }} disabled={disabled} variant={variant}