Inertia: href-prop cannot be null

Created on 13 Nov 2020  路  1Comment  路  Source: inertiajs/inertia

I use inertia-vue and implemented a paginator component wrapping Laravel's paginate() (toArray).
The links object of the response returns null when there are no previous or next pages:

// on the last page
{
    links: {
        first: 'https://url.com?page=1',
        last: 'https://url.com?page=4',
        next: null,
        prev: 'https://url.com?page=3',
    },
}

// on the first page
{
    links: {
        first: 'https://url.com?page=1',
        last: 'https://url.com?page=4',
        next: 'https://url.com?page=2,
        prev: null,
    },
}

I noticed there is a required-validator in the inertia-link component for the href-prop, and I was able omit this behaviour by sending a random string (in my case '#' and set pointer-events: none;.

Very tiny annoyance. I forked to try and apply a fix, but don't have the testing resources required to do so confidently.

To sum it all up: If the href-prop is null, I would expect the element to be rendered, but not have any click event handlers, or similar, applied.

Alternatively add a disabled-prop which would terminate early.

investigate vue 2 vue 3

Most helpful comment

I agree that the href prop shouldn't be required.

If the href-prop is null, I would expect the element to be rendered, but not have any click event handlers, or similar, applied.

However, I don't agree with this. If href is empty, it should link to the current page to mirror the a tag behaviour.

Whatever is decided, this change should apply to both the Vue 2 and Vue 3 adapters.

>All comments

I agree that the href prop shouldn't be required.

If the href-prop is null, I would expect the element to be rendered, but not have any click event handlers, or similar, applied.

However, I don't agree with this. If href is empty, it should link to the current page to mirror the a tag behaviour.

Whatever is decided, this change should apply to both the Vue 2 and Vue 3 adapters.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mpskovvang picture mpskovvang  路  5Comments

piercemcgeough picture piercemcgeough  路  4Comments

reinink picture reinink  路  5Comments

adriandmitroca picture adriandmitroca  路  5Comments

MichaelDeBoey picture MichaelDeBoey  路  4Comments