Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancements for Better Accessibility and Code Refactoring ⚙ #416

Closed
1 change: 1 addition & 0 deletions pagefind_ui/default/svelte/result.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
class="pagefind-ui__result-image"
src={data.meta?.image}
alt={data.meta?.image_alt || data.meta?.title}
decoding="async"
/>
{/if}
</div>
Expand Down
1 change: 1 addition & 0 deletions pagefind_ui/default/svelte/result_with_subs.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
class="pagefind-ui__result-image"
src={data.meta?.image}
alt={data.meta?.image_alt || data.meta?.title}
decoding="async"
/>
{/if}
</div>
Expand Down
14 changes: 5 additions & 9 deletions pagefind_ui/default/svelte/ui.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@
}
};

const showMore = (e) => {
e?.preventDefault();
const showMore = () => {
show += 5;
};
</script>
Expand All @@ -198,23 +197,20 @@
role="search"
aria-label={translate("search_label", automatic_translations, translations)}
action="javascript:void(0);"
on:submit={(e) => e.preventDefault()}
on:submit|preventDefault ={() => {}}
>
<input
class="pagefind-ui__search-input"
on:focus={init}
on:keydown={(e) => {
on:keydown|preventDefault ={(e) => {
sanjaiyan-dev marked this conversation as resolved.
Show resolved Hide resolved
if (e.key === "Escape") {
val = "";
input_el.blur();
}
sanjaiyan-dev marked this conversation as resolved.
Show resolved Hide resolved
if (e.key === "Enter") {
e.preventDefault();
}
}}
bind:value={val}
bind:this={input_el}
type="text"
type="search"
placeholder={translate("placeholder", automatic_translations, translations)}
autocapitalize="none"
enterkeyhint="search"
Expand Down Expand Up @@ -301,7 +297,7 @@
<button
type="button"
class="pagefind-ui__button"
on:click={showMore}
on:click|preventDefault={showMore}
>{translate("load_more", automatic_translations, translations)}</button
>
{/if}
Expand Down
3 changes: 2 additions & 1 deletion pagefind_ui/modular/components/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ export class Input {
.class("pagefind-modular-input")
.attrs({
autocapitalize: "none",
enterkeyhint: "search"
enterkeyhint: "search",
type: "search"
})
.addTo(wrapper);

Expand Down
3 changes: 2 additions & 1 deletion pagefind_ui/modular/components/resultList.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const resultTemplate = (result) => {
if (result?.meta?.image) {
new El("img").class("pagefind-modular-list-image").attrs({
src: result.meta.image,
alt: result.meta.image_alt || result.meta.title
alt: result.meta.image_alt || result.meta.title,
decoding: "async"
}).addTo(thumb);
}

Expand Down