File tree Expand file tree Collapse file tree 3 files changed +28
-10
lines changed
Expand file tree Collapse file tree 3 files changed +28
-10
lines changed Original file line number Diff line number Diff line change @@ -25,17 +25,20 @@ export default function useCount(
2525 showCount ?: InputProps [ 'showCount' ] ,
2626) {
2727 return React . useMemo < ForcedCountConfig > ( ( ) => {
28- let mergedConfig = count ;
29-
30- if ( ! count ) {
31- mergedConfig = {
32- show :
33- typeof showCount === 'object' && showCount . formatter
34- ? showCount . formatter
35- : ! ! showCount ,
36- } ;
28+ let mergedConfig : CountConfig = { } ;
29+
30+ if ( showCount ) {
31+ mergedConfig . show =
32+ typeof showCount === 'object' && showCount . formatter
33+ ? showCount . formatter
34+ : ! ! showCount ;
3735 }
3836
37+ mergedConfig = {
38+ ...mergedConfig ,
39+ ...count ,
40+ } ;
41+
3942 const { show, ...rest } = mergedConfig ! ;
4043
4144 return {
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ export interface InputProps
114114 string
115115 > ;
116116 onPressEnter ?: KeyboardEventHandler < HTMLInputElement > ;
117- /** @deprecated Use `count.show` instead */
117+ /** It's better to use `count.show` instead */
118118 showCount ?:
119119 | boolean
120120 | {
Original file line number Diff line number Diff line change @@ -110,5 +110,20 @@ describe('Input.Count', () => {
110110
111111 expect ( container . querySelector ( '.rc-input-out-of-range' ) ) . toBeTruthy ( ) ;
112112 } ) ;
113+
114+ it ( 'mix usage' , ( ) => {
115+ const { container } = render (
116+ < Input
117+ showCount
118+ count = { {
119+ max : 10 ,
120+ } }
121+ defaultValue = "bamboo"
122+ /> ,
123+ ) ;
124+ expect (
125+ container . querySelector ( '.rc-input-show-count-suffix' ) ?. textContent ,
126+ ) . toEqual ( '6 / 10' ) ;
127+ } ) ;
113128 } ) ;
114129} ) ;
You can’t perform that action at this time.
0 commit comments