Skip to content

Commit

Permalink
Other option should hide input value when deselected, resolves #808
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinchappell committed Oct 5, 2018
1 parent d910d73 commit ce15088
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
19 changes: 0 additions & 19 deletions src/js/control/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ export default class controlSelect extends control {
id: `${data.id}-other`,
className: `${data.className} other-option`,
value: '',
events: {
click: () => this.otherOptionCB(otherOptionAttrs.id),
},
}

let wrapperClass = optionType
Expand Down Expand Up @@ -178,22 +175,6 @@ export default class controlSelect extends control {
toggleValid()
}

/**
* Callback for 'other' option.
* Toggles the hidden text area for "other" option.
* @param {String} otherId id of the "other" option input
*/
otherOptionCB(otherId) {
const otherInput = document.getElementById(otherId)
const otherInputValue = document.getElementById(`${otherId}-value`)

if (otherInput.checked) {
otherInputValue.style.display = 'inline-block'
} else {
otherInputValue.style.display = 'none'
}
}

/**
* onRender callback
*/
Expand Down
6 changes: 6 additions & 0 deletions src/sass/_stage.scss
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,12 @@
display: block;
}

.other-option:checked + label {
input {
display: inline-block;
}
}

.other-val {
margin-left: 5px;
display: none;
Expand Down
15 changes: 10 additions & 5 deletions src/sass/base/_bs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ textarea {
.input-group-btn:first-child > .btn-group:not(:first-child) > .btn,
.input-group-btn:first-child > .btn:not(:first-child),
.input-group-btn:last-child > .btn,
.input-group-btn:last-child > .btn-group > .btn, .input-group-btn:last-child > .dropdown-toggle {
.input-group-btn:last-child > .btn-group > .btn,
.input-group-btn:last-child > .dropdown-toggle {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
Expand Down Expand Up @@ -220,10 +221,10 @@ textarea.form-control {

.fb-checkbox-group {
.checkbox,
.checkbox-inline{
.checkbox-inline {
padding-left: 0;
input {
position:relative;
position: relative;
margin: 4px 0 0;
}
label {
Expand All @@ -233,14 +234,18 @@ textarea.form-control {
}

.fb-radio-group {
.radio, .radio-inline{
.radio,
.radio-inline {
padding-left: 0;
input {
position:relative;
position: relative;
margin: 4px 0 0;
}
label {
padding-left: 4px;
input[type='text'] {
margin-top: 0;
}
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/sass/form-render.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
color: $error;
}

.other-option:checked + label {
input {
display: inline-block;
}
}

.other-val {
margin-left: 5px;
display: none;
Expand Down

0 comments on commit ce15088

Please sign in to comment.