Fixup search
Fix selecting cell 0, 0 and improve regex criteria for when cell results show vs mod results.
This commit is contained in:
parent
139257f2a0
commit
dbd6c02264
@ -28,7 +28,7 @@ for (let x = -77; x < 76; x++) {
|
|||||||
const cellSearch = new MiniSearch({
|
const cellSearch = new MiniSearch({
|
||||||
fields: ["id"],
|
fields: ["id"],
|
||||||
storeFields: ["id", "name", "x", "y"],
|
storeFields: ["id", "name", "x", "y"],
|
||||||
tokenize: (s) => [s.replace(/cell\s?/gi, "")],
|
tokenize: (s) => [s.replace(/(cell\s?)|\s/gi, "")],
|
||||||
searchOptions: {
|
searchOptions: {
|
||||||
fields: ["id"],
|
fields: ["id"],
|
||||||
prefix: true,
|
prefix: true,
|
||||||
@ -82,7 +82,13 @@ const SearchBar: React.FC<Props> = ({ counts, sidebarOpen }) => {
|
|||||||
onInputValueChange: ({ inputValue }) => {
|
onInputValueChange: ({ inputValue }) => {
|
||||||
if (inputValue) {
|
if (inputValue) {
|
||||||
let results: SearchResult[] = [];
|
let results: SearchResult[] = [];
|
||||||
if (modSearch.current && !/^(cell)?\s?-?\d+,-?\d+$/i.test(inputValue)) {
|
if (
|
||||||
|
modSearch.current &&
|
||||||
|
!/(^cell\s?-?\d+\s?,?\s?-?\d*$)|(^-?\d+\s?,\s?-?\d*$)/i.test(
|
||||||
|
inputValue
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
console.log("searching mods");
|
||||||
results = results.concat(
|
results = results.concat(
|
||||||
modSearch.current.search(inputValue).sort((resultA, resultB) => {
|
modSearch.current.search(inputValue).sort((resultA, resultB) => {
|
||||||
if (counts) {
|
if (counts) {
|
||||||
@ -109,7 +115,7 @@ const SearchBar: React.FC<Props> = ({ counts, sidebarOpen }) => {
|
|||||||
onSelectedItemChange: ({ selectedItem }) => {
|
onSelectedItemChange: ({ selectedItem }) => {
|
||||||
if (selectedItem) {
|
if (selectedItem) {
|
||||||
setSearchFocused(false);
|
setSearchFocused(false);
|
||||||
if (selectedItem.x && selectedItem.y) {
|
if (selectedItem.x !== undefined && selectedItem.y !== undefined) {
|
||||||
router.push({
|
router.push({
|
||||||
query: { cell: `${selectedItem.x},${selectedItem.y}` },
|
query: { cell: `${selectedItem.x},${selectedItem.y}` },
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user