-
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 1 commit
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 |
---|---|---|
|
@@ -11,7 +11,7 @@ import { | |
SingleSelectDumb as SingleSelect, | ||
ISingleSelectState, | ||
} from '../SingleSelect/SingleSelect'; | ||
import TextField, { ITextFieldProps } from '../TextField/TextField'; | ||
import TextField, { ITextFieldProps, ITextFieldPropsWithPassThroughs } from '../TextField/TextField'; | ||
import { IButtonProps, Button } from '../Button/Button'; | ||
import ArrowIcon from '../Icon/ArrowIcon/ArrowIcon'; | ||
import { buildModernHybridComponent } from '../../util/state-management'; | ||
|
@@ -35,6 +35,10 @@ type IPaginatorSingleSelectProps = Partial<ISingleSelectProps>; | |
|
||
type ShowTotalObjects = (count: number) => string; | ||
|
||
interface IExtendedTextFieldProps extends Omit<ITextFieldProps, 'value'> { | ||
value?: string | number | ||
} | ||
|
||
export interface IPaginatorProps | ||
extends StandardProps, | ||
React.DetailedHTMLProps< | ||
|
@@ -116,7 +120,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 { | ||
|
@@ -242,6 +246,7 @@ class Paginator extends React.Component<IPaginatorProps, IPaginatorState> { | |
event: React.FocusEvent | React.FormEvent; | ||
} | ||
): void => { | ||
console.log(pageNum); | ||
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. might want to remove the log statement here unless it's intentional |
||
const { onPageSelect, selectedPageIndex, totalPages } = this.props; | ||
const parsedPageNum = _.parseInt(pageNum); | ||
if (_.isNaN(parsedPageNum)) { | ||
|
@@ -310,11 +315,11 @@ class Paginator extends React.Component<IPaginatorProps, IPaginatorState> { | |
<ArrowIcon direction='left' /> | ||
</Button> | ||
<TextField | ||
lazyLevel={100} | ||
{...textFieldProps} | ||
lazyLevel={100} | ||
onBlur={this.handleTextFieldChange} | ||
onSubmit={this.handleTextFieldChange} | ||
isDisabled={isDisabled} | ||
isDisabled={isDisabled || textFieldProps.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. can this be covered in a test case? |
||
{...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. |
||
value={selectedPageIndex + 1} | ||
/> | ||
{!_.isNil(totalPages) && <span>of {totalPages.toLocaleString()}</span>} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
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 disabled using textFieldProps and is passed an index value.</p> | ||
|
||
<section> | ||
<Paginator | ||
hasPageSizeSelector | ||
showTotalObjects | ||
totalCount={12321313} | ||
SingleSelect={{ | ||
DropMenu: { direction: 'up' }, | ||
}} | ||
TextField={{ | ||
value: 3, | ||
isDisabled: true, | ||
}} | ||
/> | ||
</section> | ||
|
||
<p>On submit</p> | ||
|
||
<section> | ||
<Paginator | ||
hasPageSizeSelector | ||
showTotalObjects | ||
totalCount={12321313} | ||
SingleSelect={{ | ||
DropMenu: { direction: 'up' }, | ||
}} | ||
TextField={{ | ||
value: 3, | ||
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?