Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Fix search select font size and eslint

Uku Taht5d8d21f685c6
diff --git a/assets/js/dashboard/components/search-select.js b/assets/js/dashboard/components/search-select.js
index 766140af8d..04b1f68c95 100644
--- a/assets/js/dashboard/components/search-select.js
+++ b/assets/js/dashboard/components/search-select.js
@@ -1,3 +1,4 @@
+/* eslint react/jsx-props-no-spreading: 0 */
import React, {useState, useCallback} from 'react'
import {useCombobox} from 'downshift'
import classNames from 'classnames'
@@ -8,14 +9,6 @@ function selectInputText(e) {
e.target.select()
}
-function ChevronDown() {
- return (
- <svg className="h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20">
- <path stroke="#6B7280" strokeLinecap="round" strokeLinejoin="round" strokeWidth="1.5" d="M6 8l4 4 4-4"/>
- </svg>
- )
-}
-
function Spinner() {
return (
<svg className="animate-spin h-4 w-4 text-indigo-500" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
@@ -44,25 +37,22 @@ export default function SearchSelect(props) {
isOpen,
inputValue,
getToggleButtonProps,
- getLabelProps,
getMenuProps,
getInputProps,
getComboboxProps,
highlightedIndex,
getItemProps,
- selectItem,
closeMenu,
- setInputValue
} = useCombobox({
- items: items,
+ items,
onInputValueChange: (changes) => {
debouncedFetchOptions(changes)
props.onInput(changes.inputValue)
},
initialSelectedItem: props.initialSelectedItem,
- onIsOpenChange: ({isOpen, inputValue}) => {
- if (isOpen) {
- fetchOptions({inputValue, isOpen})
+ onIsOpenChange: (state) => {
+ if (state.isOpen) {
+ fetchOptions(state)
}
}
})
@@ -70,7 +60,7 @@ export default function SearchSelect(props) {
function keydown(e) {
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || e.isComposing || e.keyCode === 229) return
- if (e.key == 'Enter' && isOpen && highlightedIndex === -1) {
+ if (e.key === 'Enter' && isOpen && highlightedIndex === -1) {
closeMenu()
e.preventDefault()
}
@@ -79,34 +69,33 @@ export default function SearchSelect(props) {
return (
<div className="ml-2 relative w-full">
<div className="relative rounded-md shadow-sm" {...getToggleButtonProps()} {...getComboboxProps()}>
- <input {...getInputProps({onKeyDown: keydown})} onFocus={selectInputText} placeholder={props.placeholder} type="text" className={classNames('w-full pr-10 border-gray-300 dark:border-gray-700 hover:border-gray-400 dark:hover:border-gray-200 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm rounded-md dark:bg-gray-900 dark:text-gray-300 block', {'cursor-pointer': inputValue === '' && !isOpen})} />
+ <input {...getInputProps({onKeyDown: keydown})} onFocus={selectInputText} placeholder={props.placeholder} type="text" className={classNames('w-full pr-10 border-gray-300 dark:border-gray-700 hover:border-gray-400 dark:hover:border-gray-200 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 text-sm rounded-md dark:bg-gray-900 dark:text-gray-300 block', {'cursor-pointer': inputValue === '' && !isOpen})} />
<div className="absolute inset-y-0 right-0 flex items-center pr-2 pointer-events-none">
{ !loading && <ChevronDownIcon className="h-4 w-4 text-gray-500" /> }
{ loading && <Spinner /> }
</div>
</div>
<div {...getMenuProps()}>
- { isOpen &&
- <ul className="absolute z-10 mt-1 w-full bg-white dark:bg-gray-900 shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm">
- { !loading && items.length == 0 &&
- <li className="text-gray-500 select-none py-2 px-3">No matches found in the current dashboard. Try selecting a different time range or searching for something different</li>
- }
- { loading && items.length == 0 &&
- <li className="text-gray-500 select-none py-2 px-3">Loading options...</li>
- }
+ { isOpen && (
+ <ul className="absolute z-10 mt-1 w-full bg-white dark:bg-gray-900 shadow-lg max-h-60 rounded-md py-1 text-base ring-1 ring-black ring-opacity-5 overflow-auto focus:outline-none sm:text-sm">
+ { !loading && items.length === 0 &&
+ <li className="text-gray-500 select-none py-2 px-3">No matches found in the current dashboard. Try selecting a different time range or searching for something different</li> }
+ { loading && items.length === 0 &&
+ <li className="text-gray-500 select-none py-2 px-3">Loading options...</li> }
- {
- items.map((item, index) => (
- <li className={classNames("cursor-pointer select-none relative py-2 pl-3 pr-9", {'text-white bg-indigo-600': highlightedIndex === index, 'text-gray-900 dark:text-gray-100': highlightedIndex !== index})}
- key={`${item}${index}`}
- {...getItemProps({ item, index })}
- >
- {item}
- </li>
- ))
- }
- </ul>
- }
+ {
+ items.map((item, index) => (
+ <li
+ className={classNames("cursor-pointer select-none relative py-2 pl-3 pr-9", {'text-white bg-indigo-600': highlightedIndex === index, 'text-gray-900 dark:text-gray-100': highlightedIndex !== index})}
+ key={`${item}`}
+ {...getItemProps({ item, index })}
+ >
+ {item}
+ </li>
+ ))
+ }
+ </ul>
+ )}
</div>
</div>
)