Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Search field doesn't work on mobile device (works only on desktop)

Hello,

Something strange ...

With Laravel / VueJS ... I have a search field, when I type something inside it, it calls an API to filter the content and display the result in a table.

The filter works fine on a desktop, but doesn't work if I open the browser from my smartphone.

I get no error in the console and no error in the logs.

I have binded a variable from a pinia store to the search input field and in the component with the table I watch to this variable to filter the table.

What could prevent the filter from working only on a mobile device ?

Thanks for your help.

V

0 likes
8 replies
jlrdw's avatar

Have you tried a different browser

1 like
vincent15000's avatar

@jlrdw On desktop, all browsers work fine. On my smartphone, I only have Chrome, like on my desktop.

1 like
vincent15000's avatar

@jlrdw My wife just tested on her tablet and it works only if she clicks on Enter.

Then I checked myself and the filter works fine if I click outside the input field (on blur).

UPDATED => another test I did just now : as long as the virtual keyboard is open, the variable is not updated with the search string, when I close the virtual keyboard, the filter works fine.

So my question is : how is it possible to force updating the binded variable while the virtual keyboard is open and without blur the input field ?

1 like
jlrdw's avatar

@vincent15000

it works only if she clicks on Enter.

Yes have a click event. But on desktop do you also have a submit (enter) button?

Look at virustotal how mobile is a little different from phone.

1 like
vincent15000's avatar

@jlrdw I have solved the problem like this.

<template>
    <vini-input
        v-model="search"
        before="fa-solid fa-magnifying-glass"
        placeholder="Rechercher"
        @input="onChanged"
    ></vini-input>
</template>

<script setup>
    import { ref } from 'vue';
    import { useMainStore } from '@/stores/mainStore.js';

    const search = ref(null);

    const emit = defineEmits(['changed']);

    const mainStore = useMainStore();

    const onChanged = (event) => {
        mainStore.filters.search = event.target.value;
    };
</script>

What do you think about this solution ?

Look at virustotal how mobile is a little different from phone.

I don't know this website, it talks about suspicious files, ... I have searched on it with some keywords, but I didn't find anything.

1 like
jlrdw's avatar

@vincent15000 I was referring to:

On virus total to check a URL:

On desktop you can just hit enter.

On mobile there is an actual "search" button you hit.

On mobile you need these buttons.

1 like
vincent15000's avatar

@jlrdw Oh sorry, the website you was referring to was just to check how it works ... ok ok ;).

1 like
jlrdw's avatar
jlrdw
Best Answer
Level 75

@vincent15000 You can use mobile detect software to determine if a button needs to be shown or not. Or just show it for both desktop and mobile.

On a desktop "enter" is usually taken as a submit button press anyway.

1 like

Please or to participate in this conversation.