diff --git a/components/SearchInput.vue b/components/SearchInput.vue
index 5dab89177..6fa761b1e 100644
--- a/components/SearchInput.vue
+++ b/components/SearchInput.vue
@@ -3,11 +3,21 @@
class="search"
aria-label="search"
role="search"
- :class="{ 'is-active': isActive }"
+ :class="{
+ 'is-active': isActive,
+ 'is-open': isOpen
+ }"
>
-
+
+
+
+ @keypress.enter.prevent.stop.self="onEnter"
+ @focus.capture.native="onFocus"
+ @blur.capture.native="onBlur"
+ @keyup.delete.native="onDelete"
+ @keyup.esc.native="clear"
+ @input.native="handleInput"
+ @click.capture.native="isOpen = true"
+ >
+
+
+
+
+ {{ option.label | truncate(70) }}
+
+
+
+
+
+
+
+ {{ option.commentsCount }}
+
+
+ {{ option.shoutedCount }}
+
+
+
+
+
+ {{ option.author.name | truncate(32) }} - {{ option.createdAt | dateTime('dd.MM.yyyy') }}
+
+
+
+
+
+
+
-
diff --git a/locales/de.json b/locales/de.json
index ae7cb46da..976b39906 100644
--- a/locales/de.json
+++ b/locales/de.json
@@ -26,7 +26,9 @@
"commented": "Kommentiert"
},
"search": {
- "placeholder": "Suchen"
+ "placeholder": "Suchen",
+ "hint": "Wonach suchst du?",
+ "failed": "Nichts gefunden"
},
"settings": {
"name": "Einstellungen",
diff --git a/locales/en.json b/locales/en.json
index 2bf0affc2..f4261de61 100644
--- a/locales/en.json
+++ b/locales/en.json
@@ -26,7 +26,9 @@
"commented": "Commented"
},
"search": {
- "placeholder": "Search"
+ "placeholder": "Search",
+ "hint": "What are you searching for?",
+ "failed": "Nothing found"
},
"settings": {
"name": "Settings",
diff --git a/pages/post/_slug/index.vue b/pages/post/_slug/index.vue
index 200a9f472..330d2e38b 100644
--- a/pages/post/_slug/index.vue
+++ b/pages/post/_slug/index.vue
@@ -156,7 +156,10 @@ export default {
},
watch: {
Post(post) {
- this.post = post[0]
+ this.post = post[0] || {}
+ // if (!this.post.title) {
+ // throw new Error('404')
+ // }
this.title = this.post.title
}
},
@@ -194,7 +197,7 @@ export default {
name
}
commentsCount
- comments(orderBy: createdAt_desc) {
+ comments(first: 20, orderBy: createdAt_desc) {
id
contentExcerpt
createdAt
@@ -233,6 +236,7 @@ export default {
slug: this.$route.params.slug
}
},
+ prefetch: true,
fetchPolicy: 'cache-and-network'
}
}
diff --git a/styleguide/src/system/components/data-input/Select/Select.vue b/styleguide/src/system/components/data-input/Select/Select.vue
index 382e328d1..11753031a 100755
--- a/styleguide/src/system/components/data-input/Select/Select.vue
+++ b/styleguide/src/system/components/data-input/Select/Select.vue
@@ -111,8 +111,9 @@
v-else-if="!filteredOptions.length">
{{ noOptionsFound }} "{{ searchString }}"
-
-
-
+
@@ -224,6 +225,21 @@ export default {
type: Boolean,
default: true
},
+ /**
+ * Function to filter the results
+ */
+ filter: {
+ type: Function,
+ default: (option) => {
+ const value = option.value || option
+ return searchParts.every(part => {
+ if (!part) {
+ return true
+ }
+ return value.toLowerCase().includes(part.toLowerCase())
+ })
+ }
+ },
/**
* Message to show when no options are available
*/
@@ -246,15 +262,7 @@ export default {
}
const searchParts = this.searchString.split(' ')
- return this.options.filter(option => {
- const value = option.value || option
- return searchParts.every(part => {
- if (!part) {
- return true
- }
- return value.toLowerCase().includes(part.toLowerCase())
- })
- })
+ return this.options.filter(this.filter)
},
pointerMax() {
return this.filteredOptions.length - 1
@@ -327,7 +335,9 @@ export default {
this.pointerNext()
},
setPointer(index) {
- this.pointer = index
+ if (!this.hadKeyboardInput) {
+ this.pointer = index
+ }
},
pointerPrev() {
if (this.pointer === 0) {
@@ -335,6 +345,7 @@ export default {
} else {
this.pointer--
}
+ this.scrollToHighlighted()
},
pointerNext() {
if (this.pointer === this.pointerMax) {
@@ -342,6 +353,19 @@ export default {
} else {
this.pointer++
}
+ this.scrollToHighlighted()
+ },
+ scrollToHighlighted() {
+ clearTimeout(this.hadKeyboardInput)
+ if (!this.$refs.options || !this.$refs.options.children.length) {
+ return
+ }
+ this.hadKeyboardInput = setTimeout(() => {
+ this.hadKeyboardInput = null
+ }, 250)
+ this.$refs.options.children[this.pointer].scrollIntoView({
+ block: 'nearest'
+ });
},
selectPointerOption() {
this.handleSelect(this.filteredOptions[this.pointer])