feat(danisman): soru formunda tek seçim sıradaki soruya geçirir, geçişteki kayma düzeldi; sürüm notları ağacı, bildirimde geri al oku, üst şerit ve mobil menü düzenlemeleri (→ 2.1.4)
All checks were successful
Deploy / deploy (push) Successful in 14m11s
All checks were successful
Deploy / deploy (push) Successful in 14m11s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,11 @@ import {
|
||||
geriBildirimGonder,
|
||||
geriBildirimKorumasi,
|
||||
} from "@/features/geri-bildirim/geri-bildirim-actions";
|
||||
import {
|
||||
GERI_BILDIRIM_CAPASI,
|
||||
GERI_BILDIRIM_KUTUSU,
|
||||
geriBildirimeOdaklan,
|
||||
} from "@/features/geri-bildirim/geri-bildirim-baglantisi";
|
||||
|
||||
const BASLIK = "Bir hata mı gördün?";
|
||||
const DEVAM = "Yalın üretim metodunu benimsiyor ve fikirlerine önem veriyoruz.";
|
||||
@@ -92,6 +97,15 @@ export function GeriBildirimFormu({ className = "" }: { className?: string }) {
|
||||
}
|
||||
}
|
||||
|
||||
// Üst banttaki kısayoldan gelindiyse (#geri-bildirim) kutu yazmaya hazır
|
||||
// açılır.
|
||||
useEffect(() => {
|
||||
if (window.location.hash === `#${GERI_BILDIRIM_CAPASI}`) {
|
||||
document.getElementById(GERI_BILDIRIM_CAPASI)?.scrollIntoView();
|
||||
geriBildirimeOdaklan();
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (widget.current) window.turnstile?.remove(widget.current);
|
||||
@@ -125,7 +139,11 @@ export function GeriBildirimFormu({ className = "" }: { className?: string }) {
|
||||
// altında tek yüzey var — metin alanı kenarlıksız, buton aynı yüzeyin
|
||||
// içinde (sohbet kutusuyla aynı kalıp, DESIGN.md §4.6).
|
||||
return (
|
||||
<section aria-labelledby="geri-bildirim-baslik" className={className}>
|
||||
<section
|
||||
id={GERI_BILDIRIM_CAPASI}
|
||||
aria-labelledby="geri-bildirim-baslik"
|
||||
className={`scroll-mt-24 ${className}`}
|
||||
>
|
||||
<form onSubmit={gonder}>
|
||||
{/* Başlığın başı sabit; devamı bir kez daktilo gibi yazılır ve kalır
|
||||
(döngü yok). Görünmez tam metin aynı hücrede yer tutar ki yazı
|
||||
@@ -153,7 +171,7 @@ export function GeriBildirimFormu({ className = "" }: { className?: string }) {
|
||||
</h2>
|
||||
<div className="mt-5 rounded-2xl border border-slate-200 bg-card p-2 transition-colors duration-150 focus-within:border-primary focus-within:ring-3 focus-within:ring-ring/50">
|
||||
<Textarea
|
||||
id="geri-bildirim-mesaj"
|
||||
id={GERI_BILDIRIM_KUTUSU}
|
||||
aria-labelledby="geri-bildirim-baslik"
|
||||
value={mesaj}
|
||||
onChange={(e) => setMesaj(e.target.value)}
|
||||
|
||||
13
src/features/geri-bildirim/geri-bildirim-baglantisi.ts
Normal file
13
src/features/geri-bildirim/geri-bildirim-baglantisi.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
// Üst banttaki "Geri bildirim ver" kısayolu ile sürüm notlarındaki form
|
||||
// arasındaki tek bağ: adres, çapa ve metin kutusunun kimliği burada durur.
|
||||
|
||||
export const GERI_BILDIRIM_CAPASI = "geri-bildirim";
|
||||
export const GERI_BILDIRIM_KUTUSU = "geri-bildirim-mesaj";
|
||||
export const GERI_BILDIRIM_ADRESI = `/surum-notlari#${GERI_BILDIRIM_CAPASI}`;
|
||||
|
||||
/** Form ekrandaysa metin kutusuna odağı verir; kaydırmayı çapa yapar. */
|
||||
export function geriBildirimeOdaklan() {
|
||||
document
|
||||
.getElementById(GERI_BILDIRIM_KUTUSU)
|
||||
?.focus({ preventScroll: true });
|
||||
}
|
||||
@@ -37,6 +37,7 @@ import {
|
||||
ListChecks,
|
||||
Plus,
|
||||
Trash2,
|
||||
Undo2,
|
||||
X,
|
||||
} from "lucide-react";
|
||||
import {
|
||||
@@ -99,6 +100,7 @@ function geriAlinabilirCikar(ids: string[], baslik: string) {
|
||||
duration: 8000,
|
||||
action: {
|
||||
label: "Geri al",
|
||||
icon: <Undo2 className="size-4" aria-hidden />,
|
||||
onClick: () => {
|
||||
const simdi = listeOku().filter(
|
||||
(t) => !cikanlar.some((c) => c.t.id === t.id),
|
||||
|
||||
@@ -17,8 +17,17 @@
|
||||
// kullanıcı prop'u kazanır — @shadcn/react chunk-HBS6WEDP.js `b`), pasif
|
||||
// sorular mutlak konumda saydam durur ve ilkelin verdiği `inert`i korur;
|
||||
// DOM'da kaldıkları için gönderimde FormData önceki cevapları da toplar.
|
||||
//
|
||||
// Kırpma `overflow-clip`tir, `overflow-hidden` değil: ilkel soru değişince
|
||||
// yeni fieldset'e odak verir, o an fieldset hâlâ sağda (x: %100) durur;
|
||||
// `hidden` kutu kaydırılabilir olduğu için tarayıcı odağı göstermek üzere
|
||||
// kutuyu yana kaydırır ve soru yarım/boş görünür. `clip` hiç kaymaz.
|
||||
//
|
||||
// Tek seçimli soruda seçim yapılınca kısa bir beklemeyle sonraki soruya
|
||||
// geçilir (İleri düğmesine basılmış gibi; son soruda geçilmez, gönderim
|
||||
// adayın elindedir). Ok tuşuyla seçenekler arasında gezinirken geçilmez.
|
||||
|
||||
import { useId, useState } from "react";
|
||||
import { useEffect, useId, useRef, useState } from "react";
|
||||
import { Check, MessageSquareText } from "lucide-react";
|
||||
import { motion, useReducedMotion } from "motion/react";
|
||||
import useMeasure from "react-use-measure";
|
||||
@@ -42,6 +51,9 @@ import {
|
||||
QuestionnaireTitle,
|
||||
} from "@/components/ui/questionnaire";
|
||||
|
||||
/** Seçimin dolduğu görülsün diye otomatik geçişten önceki bekleme (ms). */
|
||||
const OTOMATIK_GECIS_BEKLEME = 220;
|
||||
|
||||
export type AnketDurumu = "acik" | "gonderiliyor" | "cevaplandi" | "kapandi";
|
||||
|
||||
export function SohbetAnketi({
|
||||
@@ -60,6 +72,15 @@ export function SohbetAnketi({
|
||||
// Yalnız aktif sorunun fieldset'i ölçülür; ref soru değişince ona geçer.
|
||||
const [olcumRef, olculer] = useMeasure();
|
||||
const hareketiAzalt = !!useReducedMotion();
|
||||
const ileriRef = useRef<HTMLButtonElement>(null);
|
||||
const okTusuylaRef = useRef(false);
|
||||
const gecisZamanlayici = useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
useEffect(
|
||||
() => () => {
|
||||
if (gecisZamanlayici.current) clearTimeout(gecisZamanlayici.current);
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
if (durum === "cevaplandi" || durum === "kapandi") {
|
||||
return (
|
||||
@@ -77,6 +98,7 @@ export function SohbetAnketi({
|
||||
const items = anket.sorular.map((s) => ({
|
||||
name: s.ad,
|
||||
required: s.zorunlu !== false,
|
||||
disabled: durum === "gonderiliyor",
|
||||
choices: s.secenekler.map((o) => ({ value: o.deger })),
|
||||
}));
|
||||
|
||||
@@ -85,6 +107,12 @@ export function SohbetAnketi({
|
||||
const varyantlar = adimGecisiVaryantlari({ hareketiAzalt, yukseklik });
|
||||
const gecis = adimGecisi(hareketiAzalt);
|
||||
|
||||
function secimdenSonraIlerle(soruIndeksi: number) {
|
||||
if (okTusuylaRef.current || soruIndeksi >= anket.sorular.length - 1) return;
|
||||
if (gecisZamanlayici.current) clearTimeout(gecisZamanlayici.current);
|
||||
gecisZamanlayici.current = setTimeout(() => ileriRef.current?.click(), OTOMATIK_GECIS_BEKLEME);
|
||||
}
|
||||
|
||||
function gonder(e: React.FormEvent<HTMLFormElement>) {
|
||||
e.preventDefault();
|
||||
if (durum === "gonderiliyor") return;
|
||||
@@ -110,6 +138,8 @@ export function SohbetAnketi({
|
||||
className="rounded-2xl border border-slate-200 bg-card p-4"
|
||||
item={aktif}
|
||||
onItemChange={(ad) => {
|
||||
// Elle İleri/Geri'ye basıldıysa bekleyen otomatik geçiş ikinci kez ilerletmesin.
|
||||
if (gecisZamanlayici.current) clearTimeout(gecisZamanlayici.current);
|
||||
setGecisBasladi(true);
|
||||
setAktif(ad);
|
||||
}}
|
||||
@@ -132,7 +162,15 @@ export function SohbetAnketi({
|
||||
</div>
|
||||
{/* Kayan sorular taşmasın diye kırpılır; 4 px'lik negatif kenar +
|
||||
fieldset'teki p-1 odak halkasına (ring-3) yer bırakır. */}
|
||||
<div className="relative -m-1 overflow-hidden">
|
||||
<div
|
||||
className="relative -m-1 overflow-clip"
|
||||
onKeyDownCapture={(e) => {
|
||||
okTusuylaRef.current = e.key.startsWith("Arrow");
|
||||
}}
|
||||
onPointerDownCapture={() => {
|
||||
okTusuylaRef.current = false;
|
||||
}}
|
||||
>
|
||||
{anket.sorular.map((s, i) => {
|
||||
const buAktif = s.ad === aktif;
|
||||
return (
|
||||
@@ -159,7 +197,17 @@ export function SohbetAnketi({
|
||||
{s.aciklama ? <QuestionnaireDescription>{s.aciklama}</QuestionnaireDescription> : null}
|
||||
<QuestionnaireChoices>
|
||||
{s.secenekler.map((o) => (
|
||||
<QuestionnaireChoice key={o.deger} value={o.deger}>
|
||||
<QuestionnaireChoice
|
||||
key={o.deger}
|
||||
value={o.deger}
|
||||
onChange={
|
||||
s.coklu
|
||||
? undefined
|
||||
: (e) => {
|
||||
if (e.currentTarget.checked) secimdenSonraIlerle(i);
|
||||
}
|
||||
}
|
||||
>
|
||||
<span>{o.etiket}</span>
|
||||
{o.aciklama ? (
|
||||
<QuestionnaireChoiceDescription>{o.aciklama}</QuestionnaireChoiceDescription>
|
||||
@@ -181,7 +229,7 @@ export function SohbetAnketi({
|
||||
<QuestionnaireActions>
|
||||
<QuestionnairePrevious size="sm" />
|
||||
<QuestionnaireSkip size="sm" />
|
||||
<QuestionnaireNext size="sm" />
|
||||
<QuestionnaireNext ref={ileriRef} size="sm" />
|
||||
<QuestionnaireSubmit size="sm" disabled={durum === "gonderiliyor"}>
|
||||
{durum === "gonderiliyor" ? "Gönderiliyor…" : "Cevapları gönder"}
|
||||
</QuestionnaireSubmit>
|
||||
|
||||
Reference in New Issue
Block a user