From 3a6f18fa234bc242bd21fe1c9d284f9c3a9fbea0 Mon Sep 17 00:00:00 2001 From: JulienM Date: Tue, 28 Jan 2020 11:36:17 +0100 Subject: [PATCH 1/2] Display null label in NullableBooleanInput --- docs/Inputs.md | 21 ++++++++++++++++++ .../img/nullable-boolean-input-null-label.png | Bin 0 -> 2050 bytes .../src/input/NullableBooleanInput.tsx | 18 ++++++++++++++- 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 docs/img/nullable-boolean-input-null-label.png diff --git a/docs/Inputs.md b/docs/Inputs.md index 47a5c33ac6d..36bdd9ca214 100644 --- a/docs/Inputs.md +++ b/docs/Inputs.md @@ -384,6 +384,27 @@ import { NullableBooleanInput } from 'react-admin'; ![NullableBooleanInput](./img/nullable-boolean-input.png) +`` doesn't display the empty option by default. If you want to customize its label and display it, you can use the `displayNull` prop. + +```jsx +import { NullableBooleanInput } from 'react-admin'; + + +``` + +```jsx +import englishMessages from 'ra-language-english'; + +englishMessages.ra.boolean.null = 'Null label'; +``` + +![NullableBooleanInput](./img/nullable-boolean-input-null-label.png) + + `` and `` also accepts the [common input props](./Inputs.md#common-input-props). ## `` diff --git a/docs/img/nullable-boolean-input-null-label.png b/docs/img/nullable-boolean-input-null-label.png new file mode 100644 index 0000000000000000000000000000000000000000..6cc1c78098ac5be5fa2cb4d932999bc6a0be39ad GIT binary patch literal 2050 zcmaKtc{~%0AIBFtA3T~ZSM)d{JlY%?$?-79avziCCQn9`BUdq%Ym2$IUvp%eV~d(B zH<1W6h!i8>e|RQNuKuNxU)8ESu({rutf~*h z=HwXPhO4^y*sCM2NGqMXr&@hBrSf7lt7K}9Hnau~iTKQKqrcyLRk}A!2vkTcy64@5b;-hdj17OZHsIEs6$e>;ezXK&lhZ1lx)w_-w%5E|&MS+~`z*fPLoxR5 zFGw=m(C*<1wT&jEn0xn^N19nGzN`2RTb>kw&xj^XoCqs&2Z@csW?VNrl6DI=#!ce( zE-%X$!N4`bd;N+2u4o&M5#fVgIWOy`c0!tN*kq=@IcZ4Eye5oO;(IM;uy^WyY{}zr z^a`j+LLvh0-(pDY8LK|=5Uk*DX>kRRqg0xfceO<#?I*73sZjkegcvvFDd*UeJ6{d1da;-}f-8PspJjcXC{bXXpEirk>~L)1EV;dhdpXZgTYe1! z$+Trm#mZL$#^pP(4UB*V*2z5vP=k zm(_3Cb%CK`fpWl}1a3720q8A|?y`0f)I1`wqM=e2aaT`>w?C*4BglE^rw$A)Fb1LM zLGkVvZHA=eR4TuPMMkp|(d=(e;yo}2E7R}JCIY)RqKtucajR)x@Ow%20E`su0scpI zrIO#G`7fIuZGNIoe-wA$3NL=H|JF1U7^2M`__a<`zbG1oarMC$*PXFvypVJ7GRhg= z!=uUPYR?}|sIjt-nvw}RJeqogaEJjbeh*K!7K@JVEr6ozZrZ@Ab( zo%W3F&z)+hKVu45X-soM%x7t{)V+dT(t(^3YLo-5f^No(gIREb7Cb>YZiv`g zW`V8JmD=FF{w+h)k?Gl1(=qhwE5{w1w=Z8K^yapEz9==Fjns3C*R|eE8a-Qdjj!h~ zoH^xAR{XkR&)e21PyBSAVyJLKtcoF5@(p2@VH6Xdlh|pg*a}9l3*UnG<(0`Ev@^Yu zYiTR;veQZyQOw>ph`?GiQ4mT78}pT*A2G5t@Kq&2@lx-_1gVhM%ArFyr`PheH+{r+ zbi|48jI;)e-oryZfT$nMcK46-vDDJ*0cE*-%u{)6_+sgCq@UB+o+>iu@rv@7vMP3S$Qs^rbx5b)^j9Y zX!C=|eK39Yw;J5;k)?opG3{MF$}*9DYzS`dRz*EGW^#wf3RCQzgc06jiwVu^%01P< z$sh_Y{zp6IbodY5iez8A?2Gw#%hN?2Q*BiKKhZKozjU-P_V;&YsGQ#geylusZUvid zQ8WGX@R(NlAMnc%b^M=v {translate('ra.boolean.null')} From 0b75ae7ab4b1aea93449948df63584658ddc00c5 Mon Sep 17 00:00:00 2001 From: JulienM Date: Tue, 28 Jan 2020 18:14:43 +0100 Subject: [PATCH 2/2] options precede on displayNull --- .../ra-ui-materialui/src/input/NullableBooleanInput.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ra-ui-materialui/src/input/NullableBooleanInput.tsx b/packages/ra-ui-materialui/src/input/NullableBooleanInput.tsx index c5b6c63ef43..e5b4cc2b8a0 100644 --- a/packages/ra-ui-materialui/src/input/NullableBooleanInput.tsx +++ b/packages/ra-ui-materialui/src/input/NullableBooleanInput.tsx @@ -71,15 +71,15 @@ const NullableBooleanInput: FunctionComponent< ? { ...options, SelectProps: { - ...(options && options.SelectProps), displayEmpty: true, + ...(options && options.SelectProps), }, InputLabelProps: { - ...(options && options.InputLabelProps), shrink: true, + ...(options && options.InputLabelProps), }, } - : { ...options }; + : options; return (