-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BWAP-806 updating paginator component to hand textField properties #1242
base: master
Are you sure you want to change the base?
Changes from all commits
6d22b07
f520924
9d3a005
5b44173
59e096d
82ab6dd
1142e6e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,10 @@ type IPaginatorSingleSelectProps = Partial<ISingleSelectProps>; | |
|
||
type ShowTotalObjects = (count: number) => string; | ||
|
||
interface IExtendedTextFieldProps extends Omit<ITextFieldProps, 'value'> { | ||
value?: string; | ||
} | ||
|
||
export interface IPaginatorProps | ||
extends StandardProps, | ||
React.DetailedHTMLProps< | ||
|
@@ -108,7 +112,7 @@ export interface IPaginatorProps | |
/** Object of TextField props which are passed thru to the underlying TextField component. */ | ||
|
||
//TextField: TextField.defaultProps; | ||
TextField: ITextFieldProps; | ||
TextField: IExtendedTextFieldProps; | ||
} | ||
|
||
export interface IPaginatorState { | ||
|
@@ -303,10 +307,10 @@ class Paginator extends React.Component<IPaginatorProps, IPaginatorState> { | |
</Button> | ||
<TextField | ||
lazyLevel={100} | ||
{...textFieldProps} | ||
onBlur={this.handleTextFieldChange} | ||
onSubmit={this.handleTextFieldChange} | ||
isDisabled={isDisabled} | ||
{...textFieldProps} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change of order would result in textFieldProps.isDisabled taking precedence over isDisabled. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good callout. Updated and added a test case as an example for this. |
||
isDisabled={isDisabled || textFieldProps.isDisabled} | ||
value={selectedPageIndex + 1} | ||
/> | ||
{!_.isNil(totalPages) && <span>of {totalPages.toLocaleString()}</span>} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from 'react'; | ||
import createClass from 'create-react-class'; | ||
import { Paginator } from '../../../index'; | ||
|
||
export default createClass({ | ||
getInitialState() { | ||
return { | ||
selectedPageIndex: 0, | ||
}; | ||
}, | ||
render() { | ||
return ( | ||
<div> | ||
<p>A paginator where textField is disabled using textFieldProps.</p> | ||
|
||
<section> | ||
<Paginator | ||
hasPageSizeSelector | ||
showTotalObjects | ||
totalCount={12321313} | ||
SingleSelect={{ | ||
DropMenu: { direction: 'up' }, | ||
}} | ||
TextField={{ | ||
isDisabled: true, | ||
}} | ||
/> | ||
</section> | ||
|
||
<p> | ||
A paginator where textField is not disabled using TextField props, but | ||
disabled from Paginator props | ||
</p> | ||
|
||
<section> | ||
<Paginator | ||
isDisabled={true} | ||
hasPageSizeSelector | ||
showTotalObjects | ||
totalCount={12321313} | ||
SingleSelect={{ | ||
DropMenu: { direction: 'up' }, | ||
}} | ||
TextField={{ | ||
isDisabled: false, | ||
}} | ||
/> | ||
</section> | ||
|
||
<p>On submit</p> | ||
|
||
<section> | ||
<Paginator | ||
hasPageSizeSelector | ||
showTotalObjects | ||
totalCount={12321313} | ||
SingleSelect={{ | ||
DropMenu: { direction: 'up' }, | ||
}} | ||
TextField={{ | ||
onSubmit: (value) => { | ||
this.setState({ selectedPageIndex: value }); | ||
}, | ||
isDisabled: true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unless covered by another storybook example - also include an example if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Covered by new storybook example |
||
}} | ||
/> | ||
</section> | ||
|
||
<p>On blur</p> | ||
|
||
<section> | ||
<Paginator | ||
hasPageSizeSelector | ||
showTotalObjects | ||
totalCount={12321313} | ||
SingleSelect={{ | ||
DropMenu: { direction: 'up' }, | ||
}} | ||
TextField={{ | ||
value: this.state.selectedPageIndex, | ||
onBlur: (value) => { | ||
this.setState({ selectedPageIndex: value }); | ||
}, | ||
}} | ||
/> | ||
</section> | ||
</div> | ||
); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need to redefine the value field?