Skip to content

Commit

Permalink
Merge pull request #1761 from rolandjohann/optional_arrow_rendering
Browse files Browse the repository at this point in the history
implemented optional rendering of arrow
  • Loading branch information
JedWatson authored Oct 19, 2017
2 parents 16f75fd + a2ca914 commit a252668
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ function onInputKeyDown(event) {

| Property | Type | Default | Description |
|:---|:---|:---|:---|
| arrowRenderer | func | undefined | Renders a custom drop-down arrow to be shown in the right-hand side of the select: `arrowRenderer({ onMouseDown, isOpen })` |
| addLabelText | string | 'Add "{label}"?' | text to display when `allowCreate` is true |
| arrowRenderer | func | undefined | Renders a custom drop-down arrow to be shown in the right-hand side of the select: `arrowRenderer({ onMouseDown, isOpen })`. Won't render when set to `null`
| autoBlur | bool | false | Blurs the input element after a selection has been made. Handy for lowering the keyboard on mobile devices |
| autofocus | bool | undefined | autofocus the component on mount |
| autoload | bool | true | whether to auto-load the default async options set |
Expand Down
5 changes: 4 additions & 1 deletion less/control.less
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@
text-align: center;
vertical-align: middle;
width: (@select-arrow-width * 5);
padding-right: @select-arrow-width;
}

.Select-arrow {
Expand All @@ -257,6 +256,10 @@
position: relative;
}

.Select-control > *:last-child {
padding-right: @select-right-padding;
}

.Select--multi .Select-multi-value-wrapper {
display: inline-block;
}
Expand Down
2 changes: 2 additions & 0 deletions less/select.less
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@
@select-loading-color: @select-text-color;
@select-loading-color-bg: @select-input-border-color;

@select-right-padding: 5px;

// multi-select item
@select-item-font-size: .9em;

Expand Down
15 changes: 15 additions & 0 deletions test/Select-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3971,6 +3971,21 @@ describe('Select', () => {
});
});

describe('arrowRenderer', () => {
beforeEach(() => {
instance = createControl({
arrowRenderer: null
});
});

it('doesn\'t render arrow if arrowRenderer props is null', () => {

var arrow = ReactDOM.findDOMNode(instance).querySelectorAll('.Select-arrow-zone')[0];

expect(arrow, 'to be', undefined);
});
});

describe('with autoFocus', () => {
it('focuses select input on mount', () => {
wrapper = createControl({
Expand Down

0 comments on commit a252668

Please sign in to comment.