Skip to content

Commit

Permalink
Fix placeholder not configurable for fieldRplSelect (#601)
Browse files Browse the repository at this point in the history
* Adds placeholder for rplselect field

* fix rpl-select error with no options

* update snapshots
  • Loading branch information
dylankelly authored Nov 26, 2019
1 parent aa77038 commit 57f7cae
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
32 changes: 17 additions & 15 deletions packages/components/Molecules/Form/Select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -228,23 +228,25 @@ export default {
return false
},
focusItem (selected) {
this.focussed = selected
const item = this.$el.querySelector(`#${selected.uuid}`)
const listbox = this.$refs.listbox
if (selected) {
this.focussed = selected
const item = this.$el.querySelector(`#${selected.uuid}`)
const listbox = this.$refs.listbox
if (listbox.scrollHeight > listbox.clientHeight) {
let scrollBottom = listbox.clientHeight + listbox.scrollTop
let elementBottom = item.offsetTop + item.offsetHeight
if (elementBottom > scrollBottom) {
listbox.scrollTop = elementBottom - listbox.clientHeight
} else if (item.offsetTop < listbox.scrollTop) {
listbox.scrollTop = item.offsetTop
if (listbox.scrollHeight > listbox.clientHeight) {
let scrollBottom = listbox.clientHeight + listbox.scrollTop
let elementBottom = item.offsetTop + item.offsetHeight
if (elementBottom > scrollBottom) {
listbox.scrollTop = elementBottom - listbox.clientHeight
} else if (item.offsetTop < listbox.scrollTop) {
listbox.scrollTop = item.offsetTop
}
}
if (item) {
this.$nextTick(function () {
item.focus()
})
}
}
if (item) {
this.$nextTick(function () {
item.focus()
})
}
},
handleKeys (e) {
Expand Down
7 changes: 2 additions & 5 deletions packages/components/Molecules/Form/fields/fieldRplselect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ export default {
computed: {
config () {
return {
multiselect: this.schema.multiselect,
placeholder: 'Select',
showitems: 4,
fieldId: this.getFieldID(this.schema),
label: ''
...this.schema,
fieldId: this.getFieldID(this.schema)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/__snapshots__/storyshots.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5403,7 +5403,7 @@ exports[`RippleStoryshots Molecules/Form Default 1`] = `
disabled="disabled"
value=""
>
Select
Select a single topic
</option>
<option
Expand Down

0 comments on commit 57f7cae

Please sign in to comment.