Skip to content

Commit

Permalink
Merge pull request #1 from samunohito/forward_hashtag_search_fix
Browse files Browse the repository at this point in the history
MkInputをpreventに対応させ、enterの意図せぬ伝搬を防ぐ
  • Loading branch information
Sayamame-beans authored Jul 24, 2024
2 parents adbc1ec + e3c5fb9 commit 8d6ad56
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
4 changes: 2 additions & 2 deletions packages/frontend/src/components/MkInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const props = defineProps<{
const emit = defineEmits<{
(ev: 'change', _ev: KeyboardEvent): void;
(ev: 'keydown', _ev: KeyboardEvent): void;
(ev: 'enter'): void;
(ev: 'enter', _ev: KeyboardEvent): void;
(ev: 'update:modelValue', value: string | number): void;
}>();

Expand Down Expand Up @@ -111,7 +111,7 @@ const onKeydown = (ev: KeyboardEvent) => {
emit('keydown', ev);

if (ev.code === 'Enter') {
emit('enter');
emit('enter', ev);
}
};

Expand Down
11 changes: 1 addition & 10 deletions packages/frontend/src/pages/search.note.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div class="_gaps">
<div class="_gaps">
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter="search">
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter.prevent="search">
<template #prefix><i class="ti ti-search"></i></template>
</MkInput>
<MkFolder>
Expand Down Expand Up @@ -75,9 +75,6 @@ async function search() {
if (query == null || query === '') return;

if (query.startsWith('https://') && !query.includes(' ')) {
//Enterの入力によって検索が開始された場合、Confirmの方にもEnterが入力されてしまうため、遅延させる
await new Promise(x => setTimeout(x, 2));

const confirm = await os.confirm({
type: 'info',
text: i18n.ts.lookupConfirm,
Expand All @@ -103,9 +100,6 @@ async function search() {

if (query.length > 1 && !query.includes(' ')) {
if (query.startsWith('@')) {
//Enterの入力によって検索が開始された場合、Confirmの方にもEnterが入力されてしまうため、遅延させる
await new Promise(x => setTimeout(x, 2));

const confirm = await os.confirm({
type: 'info',
text: i18n.ts.lookupConfirm,
Expand All @@ -117,9 +111,6 @@ async function search() {
}

if (query.startsWith('#')) {
//Enterの入力によって検索が開始された場合、Confirmの方にもEnterが入力されてしまうため、遅延させる
await new Promise(x => setTimeout(x, 2));

const confirm = await os.confirm({
type: 'info',
text: i18n.ts.openTagPageConfirm,
Expand Down
11 changes: 1 addition & 10 deletions packages/frontend/src/pages/search.user.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<div class="_gaps">
<div class="_gaps">
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter="search">
<MkInput v-model="searchQuery" :large="true" :autofocus="true" type="search" @enter.prevent="search">
<template #prefix><i class="ti ti-search"></i></template>
</MkInput>
<MkRadios v-model="searchOrigin" @update:modelValue="search()">
Expand Down Expand Up @@ -49,9 +49,6 @@ async function search() {
if (query == null || query === '') return;

if (query.startsWith('https://') && !query.includes(' ')) {
//Enterの入力によって検索が開始された場合、Confirmの方にもEnterが入力されてしまうため、遅延させる
await new Promise(x => setTimeout(x, 2));

const confirm = await os.confirm({
type: 'info',
text: i18n.ts.lookupConfirm,
Expand All @@ -77,9 +74,6 @@ async function search() {

if (query.length > 1 && !query.includes(' ')) {
if (query.startsWith('@')) {
//Enterの入力によって検索が開始された場合、Confirmの方にもEnterが入力されてしまうため、遅延させる
await new Promise(x => setTimeout(x, 2));

const confirm = await os.confirm({
type: 'info',
text: i18n.ts.lookupConfirm,
Expand All @@ -91,9 +85,6 @@ async function search() {
}

if (query.startsWith('#')) {
//Enterの入力によって検索が開始された場合、Confirmの方にもEnterが入力されてしまうため、遅延させる
await new Promise(x => setTimeout(x, 2));

const confirm = await os.confirm({
type: 'info',
text: i18n.ts.openTagPageConfirm,
Expand Down

0 comments on commit 8d6ad56

Please sign in to comment.