Skip to content

Commit

Permalink
Fix a mess of bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Apr 24, 2017
1 parent 4c4c1f6 commit 246a766
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 29 deletions.
4 changes: 2 additions & 2 deletions packages/react-widgets/src/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ let propTypes = {
onChange: PropTypes.func,
value: PropTypes.instanceOf(Date),

min: PropTypes.instanceOf(Date),
max: PropTypes.instanceOf(Date),
min: PropTypes.instanceOf(Date).isRequired,
max: PropTypes.instanceOf(Date).isRequired,

currentDate: PropTypes.instanceOf(Date),
onCurrentDateChange: PropTypes.func,
Expand Down
10 changes: 4 additions & 6 deletions packages/react-widgets/src/Combobox.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,15 +203,13 @@ class Combobox extends React.Component {
if (e.defaultPrevented)
return

if (key === 'End') {
if (key === 'End' && isOpen) {
e.preventDefault()
if (isOpen) this.setState({ focusedItem: list.last() })
else select(list.last(), true)
this.setState({ focusedItem: list.last() })
}
else if (key === 'Home') {
else if (key === 'Home' && isOpen) {
e.preventDefault()
if (isOpen) this.setState({ focusedItem: list.first() })
else select(list.first(), true)
this.setState({ focusedItem: list.first() })
}
else if (key === 'Escape' && isOpen)
this.close()
Expand Down
18 changes: 9 additions & 9 deletions packages/react-widgets/src/ComboboxInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ class ComboboxInput extends React.Component {
};

componentDidUpdate() {
var input = findDOMNode(this)
, val = this.props.value;
let input = findDOMNode(this)
let val = this.props.value;

if (this.isSuggesting()) {
var start = val.toLowerCase().indexOf(this._last.toLowerCase()) + this._last.length
, end = val.length - start
let start = val.toLowerCase().indexOf(this._last.toLowerCase()) + this._last.length
let end = val.length - start

if (start >= 0) {
if (start >= 0 && end !== 0) {
caretSet(input, start, start + end)
}
}
Expand All @@ -40,8 +40,8 @@ class ComboboxInput extends React.Component {
handleChange = (e) => {
let { placeholder, value, onChange } = this.props;

var stringValue = e.target.value
, hasPlaceholder = !!placeholder
let stringValue = e.target.value
let hasPlaceholder = !!placeholder

// IE fires input events when setting/unsetting placeholders.
// issue #112
Expand Down Expand Up @@ -79,8 +79,8 @@ class ComboboxInput extends React.Component {
}

accept() {
var value = findDOMNode(this).value || ''
, end = value.length;
let value = findDOMNode(this).value || ''
let end = value.length;

this._last = null
caretSet(findDOMNode(this), end, end)
Expand Down
3 changes: 3 additions & 0 deletions packages/react-widgets/src/DateTimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ let propTypes = {
delay: PropTypes.number,
dropUp: PropTypes.bool,
duration: PropTypes.number,
calendarDuration: PropTypes.number,

placeholder: PropTypes.string,
name: PropTypes.string,
Expand Down Expand Up @@ -334,6 +335,7 @@ class DateTimePicker extends React.Component {
open
, value
, duration
, calendarDuration
, dropUp } = this.props;

let calendarProps = Props.pick(this.props, Calendar);
Expand Down Expand Up @@ -362,6 +364,7 @@ class DateTimePicker extends React.Component {
aria-hidden={!open}
aria-live='polite'
aria-labelledby={inputId}
duration={calendarDuration}
/>
</Popup>
)
Expand Down
11 changes: 2 additions & 9 deletions packages/react-widgets/src/DropdownList.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ class DropdownList extends React.Component {
ref="input"
onBlur={this.focusManager.handleBlur}
onFocus={this.focusManager.handleFocus}
onClick={this.handleClick}
onKeyDown={this.handleKeyDown}
onKeyPress={this.handleKeyPress}
className={cn(className, 'rw-dropdown-list')}
Expand All @@ -262,6 +261,7 @@ class DropdownList extends React.Component {
focused={focused}
disabled={disabled}
readOnly={readOnly}
onClick={this.handleClick}
className="rw-widget-input"
>
<DropdownListInput
Expand Down Expand Up @@ -308,14 +308,7 @@ class DropdownList extends React.Component {

@widgetEditable
handleClick = (e) => {
var wrapper = this.refs.filterWrapper

if( !this.props.filter || !this.props.open )
this.toggle()

else if( !contains(findDOMNode(wrapper), e.target))
this.close()

this.toggle()
notify(this.props.onClick, e)
};

Expand Down
2 changes: 1 addition & 1 deletion packages/react-widgets/src/MultiselectTagList.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class MultiselectTagList extends React.Component {
};

handleDelete = (item, event) => {
if (!this.props.disabled)
if (this.props.disabled !== true)
this.props.onDelete(item, event)
};

Expand Down
5 changes: 3 additions & 2 deletions packages/storybook/stories/DropdownList.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ storiesOf('DropdownList', module)
<Container>
<DropdownList
{...props}
open
defaultOpen
filter
disabled={[props.data[2]]}
defaultValue={props.data[1]}
/>
Expand All @@ -110,7 +111,7 @@ storiesOf('DropdownList', module)
<Container>
<DropdownList
{...props}
open
defaultOpen
disabled={props.data.slice(0, 2)}
/>
</Container>
Expand Down

0 comments on commit 246a766

Please sign in to comment.