mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-10-18 19:10:45 +08:00
committed by
Rūdolfs Ošiņš
parent
ba5e571337
commit
e97af99286
@@ -105,6 +105,12 @@
|
||||
? submitActiveVariant
|
||||
: submitVariant,
|
||||
);
|
||||
const submitDisabled = $derived(
|
||||
!isValid() ||
|
||||
submitInProgress ||
|
||||
disableSubmit ||
|
||||
(disallowEmptyBody && body.trim() === ""),
|
||||
);
|
||||
|
||||
let selectionStart = $state(body.length);
|
||||
let selectionEnd = $state(body.length);
|
||||
@@ -287,6 +293,13 @@
|
||||
console.error(e);
|
||||
});
|
||||
}
|
||||
|
||||
export function triggerSubmit() {
|
||||
if (submitDisabled) {
|
||||
return;
|
||||
}
|
||||
submitFn();
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -517,10 +530,7 @@
|
||||
<Button
|
||||
variant={effectiveSubmitVariant}
|
||||
title={emptyBodyTooltip}
|
||||
disabled={!isValid() ||
|
||||
submitInProgress ||
|
||||
disableSubmit ||
|
||||
(disallowEmptyBody && body.trim() === "")}
|
||||
disabled={submitDisabled}
|
||||
onclick={submitFn}>
|
||||
{#if submitInProgress}
|
||||
Saving…
|
||||
@@ -600,10 +610,7 @@
|
||||
<Button
|
||||
variant={effectiveSubmitVariant}
|
||||
title={emptyBodyTooltip}
|
||||
disabled={!isValid() ||
|
||||
submitInProgress ||
|
||||
disableSubmit ||
|
||||
(disallowEmptyBody && body.trim() === "")}
|
||||
disabled={submitDisabled}
|
||||
onclick={submitFn}>
|
||||
{#if submitInProgress}
|
||||
Saving…
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
import { onMount } from "svelte";
|
||||
|
||||
import * as utils from "@app/lib/utils";
|
||||
|
||||
interface Props {
|
||||
autofocus?: boolean;
|
||||
autoselect?: boolean;
|
||||
@@ -15,6 +17,7 @@
|
||||
onFocus?: () => void;
|
||||
onBlur?: () => void;
|
||||
onSubmit?: () => void;
|
||||
onModifierSubmit?: () => void;
|
||||
oninput?: FormEventHandler<HTMLInputElement>;
|
||||
placeholder?: string;
|
||||
type?: string;
|
||||
@@ -35,6 +38,7 @@
|
||||
onFocus,
|
||||
onBlur,
|
||||
onSubmit,
|
||||
onModifierSubmit,
|
||||
oninput,
|
||||
placeholder,
|
||||
type = "text",
|
||||
@@ -65,6 +69,13 @@
|
||||
|
||||
function handleKeydown(event: KeyboardEvent) {
|
||||
event.stopPropagation();
|
||||
const auxiliarKey = utils.isMac() ? event.metaKey : event.ctrlKey;
|
||||
if (auxiliarKey && event.key === "Enter" && onModifierSubmit) {
|
||||
event.preventDefault();
|
||||
onModifierSubmit();
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key === "Enter" && valid && onSubmit) {
|
||||
onSubmit();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
|
||||
const { repo }: Props = $props();
|
||||
|
||||
let commentBox: ExtendedTextarea | undefined = $state();
|
||||
let preview = $state(false);
|
||||
let title = $state("");
|
||||
let body = $state("");
|
||||
@@ -155,10 +156,12 @@
|
||||
placeholder="Title"
|
||||
autofocus
|
||||
onDismiss={hide}
|
||||
onModifierSubmit={() => commentBox?.triggerSubmit()}
|
||||
bind:value={title} />
|
||||
{/if}
|
||||
|
||||
<ExtendedTextarea
|
||||
bind:this={commentBox}
|
||||
textAreaSize="fixed-height"
|
||||
disableSubmit={title.trim() === ""}
|
||||
disallowEmptyBody
|
||||
|
||||
Reference in New Issue
Block a user