The Doctor Saw the Newborn and Broke Into Tears. Then He Told the Mother a Truth That Had Been Buried for Twenty-Eight Years..013

The Doctor Saw the Newborn and Broke Into Tears. Then He Told the Mother a Truth That Had Been Buried for Twenty-Eight Years..013
Posted June 21, 2026The Doctor Saw the Newborn and Broke Into Tears.
Then He Told the Mother a Truth That Had Been Buried for Twenty-Eight Years.
Joanna had learned, in the quietest and cruelest way possible, that some kinds of loneliness did not arrive with shouting. They arrived with a folded bag, a closed front door, and a man who never came back.

She lay in the hospital bed at Mercy Creek Medical, her hair damp against her temples, her body shaking from the force of labor that had torn through her for twelve endless hours. The room smelled like antiseptic, clean sheets, and the metallic sting of fear. A monitor beeped beside her in an impatient rhythm. Somewhere beyond the curtain, nurses moved quickly in soft shoes. Somewhere far away, a baby cried, and Joanna felt her own heart crack open at the sound.
Then the cry came from beside her.
Her son.
Tiny. Red-faced. Wrinkled. Furious at being pulled into the world, and already making his opinion known with every breath.
Joanna stared at him through tears she could hardly see through. He was here. He was alive. He was hers. She let out a trembling laugh that turned into a sob, and one of the nurses smiled as she adjusted the blanket around the newborn.
“You did well,” the nurse said gently.
Joanna could barely speak. “Is he okay?”
“He’s perfect,” the nurse answered.
Joanna shut her eyes. Perfect. The word hit her like a blessing she had almost stopped believing in.
Seven months earlier, Logan Wright had walked out of her apartment without raising his voice, without even slamming the door. That had been worse somehow. If he had shouted, maybe anger could have kept him there. If he had begged, maybe love would have had a shape she could hold on to. But Logan had only looked at her with an expression she still could not understand and said, “I need some time.”
She had been standing barefoot in the kitchen then, one hand resting over the small curve of her stomach, the other gripping the counter so tightly her knuckles turned white.
“Time for what?” she had asked.
He had not answered.
He had simply taken his jacket, stared at her like he was memorizing her face, and left.
After that, she cried until she had no tears left. Then she worked. Diner shifts. Late nights. Early mornings. Plates. Coffee. Bills. Tips counted by the kitchen light. She rented a room above a laundromat on the edge of town because it was cheap and the walls were thin enough to hear every neighbor’s life but not her own. She stopped waiting for Logan’s calls after the third week. By the fourth, she stopped checking the phone altogether.
Still, every night, she talked to the life inside her.
“I’m here,” she whispered to her growing belly when she could no longer sleep. “I’m not going anywhere.”
That promise had carried her through the worst of the pain, through the fear, through the awful nights when she woke from dreams of empty cribs and silent hallways with one hand pressed to her stomach as if to make sure the baby was still there.
And now he was.
Now the nurse was lowering him toward Joanna’s arms.
That was when the door opened.
The movement was small, almost ordinary, but it changed the whole room. A middle-aged man stepped inside in a white doctor’s coat, a patient chart tucked under one arm. He had thick brown hair streaked with silver at the temples, steady shoulders, and the controlled kind of face people trusted in emergencies. Dr. Robert Wright.
Joanna only knew his name from the chart clipped to the foot of her bed.
The room seemed to tighten around him as soon as he entered. He glanced at the chart once, then at the baby, and whatever he saw there stole the color from his face so quickly Joanna thought, absurdly, that he might be sick.
His fingers went slack around the chart.
His mouth parted.
The newborn gave another small, angry cry.
And Robert Wright went absolutely still.
The nurse noticed before Joanna did. “Doctor?”
He did not answer.
He stared at the baby as if he had seen a ghost walk into the room wearing a blanket.
Joanna tried to sit up farther, alarm slicing through the exhaustion in her body. “What is it? Is something wrong?”
But the doctor’s gaze had locked on the child’s face. His breathing had become shallow. His hand, the one still holding the chart, began to shake.
Then his eyes filled.
Not with the polite shine of a man trying not to feel too much.
With real tears.
The kind that come when the body gives up hiding the truth.
The nurse looked from him to the baby and back again, her own face draining of color. “Doctor?”
Robert swallowed hard. His voice, when it came, was barely a whisper. “Where did you say she was from?”
Joanna frowned through the haze of pain and confusion. “She?”
The doctor didn’t seem to hear her correction. His gaze was fixed on the infant’s face, on the tiny ear, the curve of the brow, something so small and specific that it should have meant nothing and apparently meant everything.
Then he looked at Joanna.
Really looked at her.
And something in his expression changed again, as if the shock had split open to reveal a second shock underneath it.
“Joanna,” he said, and it was so strange hearing her own name in his mouth that she flinched. “What is your mother’s name?”
The question landed like a slap.
The nurse beside him straightened in alarm. “Doctor Wright—”
“No,” he said, still staring at Joanna, his voice breaking. “I need to know. Now.”
Joanna’s pulse pounded painfully in her throat. “Why are you asking me that?”
Robert took one step closer to the bed. He seemed to be fighting for breath. “Because I know that face.”
The room went dead quiet.
Even the monitor seemed to beep more softly.
Joanna stared at him. “What are you talking about?”
His eyes glistened. “I know that face because I have seen it before.”
A cold, strange sensation crawled up her spine. “On the baby?”
He shook his head once, almost violently. “No.” His gaze dropped to the blanket in her arms, then lifted again to her face. “On you.”
Joanna felt the blood drain from her own cheeks.
“That’s impossible,” she whispered.
Robert’s lips trembled. For one horrible second, he looked less like a doctor and more like a man standing at the edge of a grave he had dug himself. “Please,” he said, and there was a raw pleading in it that no one in a hospital should ever have to hear from a man in a white coat. “Does the name Elena Carter mean anything to you?”
Joanna’s mind went blank.
The baby wriggled in her arms, rooting against the blanket, angry and hungry and alive. Joanna clung to the feel of him like it might keep her from slipping under.
“Elena…?” she repeated.
Robert’s eyes shut briefly. When they opened, tears had already escaped and run down his face. “My wife’s sister,” he said. “She worked in pediatrics at Mercy Creek twenty-eight years ago.”
Joanna stared at him, confused and suddenly afraid of the answer waiting behind his words.
“I’m sorry,” she said. “I don’t know what this has to do with me.”
“It has everything to do with you,” Robert said.
The nurse made a small sound of protest. “Doctor, maybe we should—”
He lifted one hand without looking away from Joanna. “Give us a minute.”
The nurse hesitated, then slipped out with the other staff member, pulling the curtain partly closed behind them. The room felt too small now, too warm. Joanna’s wound throbbed. Her arms ached around the baby. But it was the doctor’s face that scared her most of all: the way his control had vanished, the way he looked caught between grief and revelation.
He moved closer to the bed, slower now, like he was afraid a sudden movement might break something already fragile.
“Joanna,” he said quietly, “how old are you?”
“What kind of question is that?”
“Please.”
She swallowed. “Twenty-six.”
His eyes closed again.
When he opened them, there was no doubt left in his face. Only devastation.
“No,” he murmured. “No, it can’t be…”
Joanna’s fear sharpened into anger now. “What is wrong with you? If this is about the baby—”
“It’s not about the baby.” His voice cracked on the last word. He swallowed hard and looked down at the newborn one more time, as if he needed the pain of seeing him to stay upright. “It’s about the girl who should have been in your place.”
Joanna went very still.
Robert took a trembling breath. “There was a fire in the maternity wing at Mercy Creek twenty-six years ago. Electrical fault. We lost power in half the unit. One newborn was moved out before the smoke spread. Another was… reported dead.”
The room tilted.
Joanna felt every sound recede to a distant hiss.
“I don’t understand,” she whispered.
Robert looked at her like a man asking forgiveness from heaven itself. “That baby was my daughter.”
Joanna blinked at him.
Then again.
And the shape of his words, their impossible meaning, slammed into her so hard she thought she might faint.
“No,” she said, because there was nothing else. “That’s not—my mother died when I was little. She never said anything about—”
“The woman who raised you wasn’t your biological mother,” Robert said gently.
Joanna’s head snapped up.
The air seemed to vanish.
For a moment she could not speak. Could not breathe. Her body, exhausted and broken from childbirth, reacted only with a cold, stunned refusal.
“That’s a lie,” she said.
“I wish it were.” His voice was ragged now. “I have spent twenty-six years trying to prove it wasn’t.”
Joanna stared at him, the baby heavy and warm in her arms. Her own heartbeat sounded loud enough to hurt. “You’re saying I’m some kind of lost child? That my life is just… what? A mistake?”
Robert made a broken sound. “No. I’m saying you are my daughter.”
The world stopped.
Not slowed. Not blurred.
Stopped.
Joanna felt the words strike some deep place inside her that had gone untouched her whole life, a place she had not even known was waiting for them. She searched his face for cruelty, for manipulation, for the kind of lie rich or powerful people told when they wanted something from a poor woman in a hospital bed.
But there was none of that.
Only grief.
Only truth.
Only the terrible collapse of a man who had just seen his lost child in the face of a woman he had never stopped searching for.
Joanna tried to laugh, but it came out as a sob.
“No,” she said again, weaker now. “No, I would know. I would know if something like that happened to me.”
Robert reached into his coat with shaking fingers and pulled out a small worn object wrapped in plastic. He held it out carefully.
A baby bracelet.
The ink on the paper was faded, but the name was still visible.
Baby Girl Carter.
Joanna stared at it.
Her own hands began to shake.
Under the bracelet was a tiny silver charm shaped like a teardrop, dented on one side.
She knew that charm.
Not because she had seen it before.
Because she had dreamed about it for as long as she could remember.
She looked up at him, horror and disbelief racing across her face. “Where did you get that?”
Robert was crying openly now, no attempt left at restraint. “From the emergency records box they forgot to destroy.”
Joanna’s mouth went dry.
“The nurse who took you that night,” he said, and his voice had become very soft, very old, “was my sister-in-law, Elena Carter. She told me you died in the transfer. I believed her for six years. Then I found your bracelet in an old archive box when the wing was renovated. I started digging. I found inconsistencies. I found a signature that did not belong. I found a report that had been edited. But every time I got close, the records disappeared.”
Joanna shook her head violently. “Why are you telling me this now?”
His gaze dropped to the baby in her arms.
“Because he has your face.”
She looked down at the newborn, at his tiny clenched fists, his furious mouth, the damp lashes against his cheeks.
“No,” she whispered.
But her own reflection in the hospital window—pale, exhausted, dark-haired, eyes too large for her face—rose in memory beside the baby’s features. A terrible, impossible recognition bloomed in her chest.
Robert was breathing hard. “And because he has mine.”
It took her a second to understand.
When she did, she felt a strange flash of nausea.
“No,” she whispered again, this time with more force. “No, the baby is Logan’s.”
Robert looked at her sharply. “Logan Wright?”
She froze.
The name in his mouth felt like a blade.
“How do you know Logan?”
Her lips parted, but she didn’t answer. Couldn’t. Not while her mind was spinning through the wreckage of everything she thought she knew.
Robert saw the answer in her face anyway.
His expression changed again, this time with a new kind of pain. “He is my son,” he said quietly.
Joanna’s shock was so complete it went past emotion and became a physical sensation, as if the floor had tilted and locked into a bad angle beneath her.
“No,” she breathed. “No, he—he left me.”
Robert’s jaw tightened. “I know.”
That was almost worse.
Joanna stared at him. “You know?”
“Yes.”
She felt the room press in on her. “Then explain it.”
Robert looked older suddenly. Not because of age, but because the weight of old mistakes had found its way back into his bones.
“I raised Logan after his mother died,” he said. “He was never my biological son, but he was mine in every way that mattered. His mother was a patient here. She died in the same fire that took the records. I adopted him when he was two. He grew up with my name, my house, my rules. He never knew why I was obsessed with Mercy Creek’s old archives. He only knew I carried grief like a second spine.”
Joanna stared at him. The world had gone from broken to shattered to something beyond language.
Robert took another breath. “Logan found out about you six months ago.”
She stopped.
“What?”
“He came to me after he saw a notation in the old files. A missing baby. A name that matched the bracelet. He recognized the handwriting on one of the cards from Elena Carter’s records. He started asking questions I could not answer safely.”
Joanna’s heart thudded painfully. “Safely?”
Robert nodded once. “There are people who would rather the truth stayed buried. Elena was one of them. She had been paid to place you with a family that would never look too closely. When I got close to exposing her, she warned me that if I made noise, the records would vanish and so would the people who had seen them.”
The room spun.
Joanna gripped the rail of the bed with one hand. The other still held her son.
The son.
Her son.
And somehow, impossibly, the same room now contained three lives tied together by secrets, lies, and a broken hospital lie that had begun before she could speak her own name.
“Why didn’t Logan tell me?” she whispered.
Robert’s face twisted.
“Because he thought he was protecting you.”
Joanna laughed once, bitter and disbelieving. “By disappearing?”
“He came to me the night he left,” Robert said. “He’d learned enough to know that your life had already been manipulated once. He said if he stayed, whoever had arranged your disappearance might come after you again. He wanted proof first. He wanted a clean answer before he came back to you.”
Joanna closed her eyes.
All those nights she had sat on her narrow bed and listened to the silence, believing it was proof that she had never mattered enough to stay for. And all this time, he had been out there chasing ghosts and files and threats she had never known existed.
“Why didn’t he call?”
Robert looked at her sadly. “Because he thought you might be safer hating him than loving him in the dark.”
The silence in the room was brutal.
Joanna’s eyes burned. Her throat was tight enough to hurt. She looked down at the newborn, at the tiny face that had started this avalanche, and a new terror rose in her.
“What does this mean?” she asked.
Robert’s eyes returned to the baby. “It means,” he said very softly, “that the child in your arms may be the one thing that finally forces the people who buried your life to come back into the light.”
It was not what she had expected.
It was worse.
And better.
And impossible.
A knock sounded at the door, sharp and urgent. Before Joanna could answer, it opened and Logan Wright stood there, soaked from rain, hair damp and pushed back from his face, a manila envelope clenched in his hand like it was the only thing keeping him upright.
For one second, no one moved.
Then Logan saw Joanna awake in the bed, the baby in her arms, Robert standing beside her with tears still drying on his face.
And his face crumpled.
“Joanna,” he said, and the sound of her name in his voice after all those months split something deep inside her. “I’m sorry.”
She looked at him.
Really looked.
There were shadows beneath his eyes, a bruise on his jaw she had never seen, exhaustion carved into his face like he had not slept in weeks. He was not clean, not polished, not the version of himself she remembered from the days before the secrets. He looked like a man who had been fighting a war alone.
And suddenly she knew the truth before he said it.
He had not left for another woman.
He had not left because he stopped loving her.
He had left because he had found something monstrous and had been trying, all this time, to bring her the truth without letting it kill her first.
Logan took one step into the room, then another.
His eyes fixed on the baby and widened in stunned wonder.
“He’s here,” he whispered.
Joanna’s voice shook with fury and pain and hope all at once. “You disappeared.”
Logan flinched like she had struck him.
“I know.”
“You left me pregnant.”
“I know.”
“You let me think I was alone.”
He closed his eyes for a second. When he opened them, they were wet. “I know.”
The anger in her began to break under the weight of the baby’s warmth against her chest. She hated that it did. Hated that part of her still wanted to reach for him. Hated that she could not stop loving the man who had vanished from her life.
Robert looked between them, grief softening into something almost reverent.
Logan lifted the envelope. “I found her.”
Joanna stared. “Who?”
“The nurse,” he said. “Elena Carter. The one who signed the transfer records. She’s alive. She’s in Cedar Bend with her brother. I found where she’d been hiding after the clinic audit. And I found the original note.”

Robert drew in a sharp breath. “You did?”
Logan nodded.
Then he turned to Joanna and his voice lowered, trembling now with the force of what he was about to say.
“The baby isn’t just the reason I came back,” he said. “He’s the reason I stayed away.”
Joanna frowned through her tears. “What does that mean?”
Logan swallowed hard and looked at Robert.
Then back at her.
Then he said the words that made the floor feel like it had dropped away entirely.
“Because the night I found the records, I found out you were not only the woman I loved.”
His voice cracked.
“You were Robert’s daughter.”
For a moment, Joanna could not understand the sentence.
Then she did.
And understood why Logan’s face had gone pale, why he had gone silent, why he had disappeared with the weight of that knowledge crushing him.
She stared at him, horrified. “You knew before you left?”
He nodded.
“And you still—”
“I still loved you,” he said fiercely. “God help me, I still did. But when I realized who you were, and what the old records meant, I had to make sure you were never trapped by it. I was afraid if I told you too soon, before I had the papers, before I had Elena, before I had proof, someone would make you disappear again.”
Joanna’s lungs stopped working for a second.
Robert’s knees nearly gave out beside her bed. He caught the rail, staring at Logan as if he had just been handed a miracle and a wound in the same breath.
Joanna looked from one man to the other, from the doctor who had found his lost daughter in the face of her baby, to the man she had mourned every day for seven months, now standing in front of her with the truth in his hand.
“You left me thinking you were gone,” she whispered.
Logan stepped closer, careful, as if she might break. “I left because I didn’t want the truth to swallow you before you were ready.”
Her laugh came out wet and angry. “So instead you let me drown in silence?”
His face twisted. “Yes.”
The honesty of it hit harder than any excuse would have.
He didn’t defend himself. Didn’t beg for mercy. Just stood there and took it.
That, more than anything, made her believe him.
Robert reached into his coat again, this time pulling out a second envelope. “There’s more,” he said quietly.
Joanna felt dread rise again. “More?”
He nodded. “Elena’s signature was forged on the adoption transfer. But not by her.”
The room went perfectly still.
“It was your mother,” he said to Joanna.
Joanna stared. “My mother died when I was four.”
“No,” Robert said, voice soft as ash. “The woman who raised you died when you were four. Your biological mother was Elena’s sister. She worked the maternity floor. She was the one who begged me to keep looking after the fire. She died from smoke inhalation three days later. Before she died, she left a sealed note with your bracelet.”
Joanna’s hands had gone numb.
Robert handed her the envelope.
Inside was a single folded paper, yellowed with age.
Her fingers trembled as she opened it.
The handwriting was faint but unmistakable.
If my daughter survives, tell her her name was always Hope.
Joanna’s vision blurred instantly.
The room vanished around her. She heard only her own blood pounding in her ears, the baby’s tiny breathing, the sound Logan made when he choked on a sob.
Hope.
That had been the secret buried beneath her whole life.
Not abandonment. Not accident.
Hope.
Robert covered his mouth with one hand, eyes full again. “I never knew whether you lived,” he whispered. “I spent years looking for a little girl with a crescent mark on her wrist and a silver teardrop charm. Every dead end made me feel like I was dying by inches.”
Joanna stared at the note, then at him.
And suddenly she understood him too.
This man had not merely been a doctor crying over a newborn.
He had been a father who had lost a daughter before he had ever gotten to speak her name aloud.
The truth had been there all along, hidden beneath other people’s shame and fear and greed, waiting for the right moment to rise.
Logan stepped closer to the bed, voice rough. “Joanna, I didn’t come back because I wanted to explain. I came back because I couldn’t let you go through this alone again.”
She looked at him, and the love she felt was so fierce it scared her.
“You should have told me,” she whispered.
“I know.”
“You should have trusted me.”
“I know.”
“You should have stayed.”
He closed his eyes, and when he opened them, there were tears in them now too. “I’m here now.”
It was not enough.
It was also everything.
The baby made a small sound in her arms, a tiny dissatisfied squawk that broke the tension in the room. Joanna looked down and, despite the tears, a laugh escaped her. Such a small, ordinary sound. Such a ridiculous interruption in the middle of a life collapsing and rebuilding around her.
Robert let out a shaky breath that sounded almost like a laugh too.
Logan smiled through his tears, and the expression on his face was so exhausted and hopeful that Joanna’s anger lost some of its grip.
She looked at the three of them: the man who had found her at last, the man who had not abandoned her after all, and the tiny boy who had somehow dragged every buried truth into the light simply by being born.
The room no longer felt empty.
It felt crowded with the past.
And maybe, finally, with the beginning of a future.
Robert wiped his face with the heel of one hand and took a careful step back. “I should let you hold him without me shaking all over him.”
Joanna let out another tearful laugh. “You’re the one who started shaking first.”
He gave a broken smile. “Fair.”
Then his expression softened as he looked at the child again. “May I?”
Joanna hesitated only a second before nodding.
Very gently, Robert leaned in and touched one finger to the baby’s tiny hand. The newborn wrapped his small fist around the doctor’s finger with surprising strength.
Robert’s breath hitched.
The sound that left him then was not quite a sob and not quite a laugh. It was the sound of a man meeting the family he had thought dead.
Logan watched them both with a rawness that almost hurt to see.
Joanna looked at him. “What did you name the file?”
He frowned, confused. “What?”
“The envelope,” she said. “You said you found her. What did you call the file?”
His eyes searched hers, then fell to the baby. “I didn’t name the file,” he said softly. “I named what came after.”
He reached into the envelope one last time and pulled out a tiny hospital band that had been preserved in plastic for years. On it, faded but legible, was the same word Robert had just read from the note.
Hope.
Joanna looked down at the infant in her arms.
Then she looked at the man who had once walked away from her and the man who had just found her.
And for the first time in her life, the word did not feel like a prayer whispered into the dark.
It felt like a door opening.
Outside the room, rain tapped quietly at the hospital windows.
Inside, Joanna pressed her forehead to her son’s soft hair and finally let herself cry the way she had not allowed herself to cry in months—not from abandonment this time, but from the crushing, unbelievable mercy of being found.
By a father who had never stopped searching.
By a man who had never truly left.
By a child who had arrived just in time to drag the truth into the light.
And as the newborn gripped her finger, Joanna realized the most shocking thing of all:
Her life had not been ruined by the secrets.
It had been waiting for the truth to begin.
Report this article
Select a reason for reporting:
May you like
Comments 0
Posting as Guest '; } return; } var normalizedItems = items.slice().reverse(); var html = normalizedItems.map(function(comment) { var replies = Array.isArray(comment.replies) ? comment.replies : []; var repliesHtml = replies.map(function(reply) { return '' + '' + '' + '' + '' + escapeHtml(reply.author_name) + '' + escapeHtml(reply.time) + '' + '' + escapeHtml(reply.content) + '
' + '' + '' + '' + ''; }).join(''); return '' + '' + '' + '' + '' + escapeHtml(comment.author_name) + '' + escapeHtml(comment.time) + '' + '' + escapeHtml(comment.content) + '
' + '' + '' + '' + '' + (repliesHtml ? '' + repliesHtml + '' : '') + ''; }).join(''); if (mode === 'prepend') { listEl.insertAdjacentHTML('afterbegin', html); return; } listEl.insertAdjacentHTML('beforeend', html); } async function loadComments(page, mode) { var query = new URLSearchParams({ post_slug: postSlug, page: String(page), per_page: String(perPage), }); var response = await fetch('/api/post-comments?' + query.toString(), { method: 'GET', headers: { 'Accept': 'application/json' } }); var data = await response.json().catch(function() { return {}; }); if (!response.ok || data.ok === false) { throw new Error((data && data.message) || 'Cannot load comments.'); } var pagination = data.pagination || {}; currentPage = Number(pagination.current_page || 1); lastPage = Number(pagination.last_page || 1); totalCountEl.textContent = String((data.post && data.post.comment_count) || pagination.total || 0); loadMoreBtn.classList.toggle('comment-box__hidden', currentPage >= lastPage); renderComments(data.comments || [], mode); } async function postComment(content, parentId, feedbackTarget, submitTarget) { var authorName = ensureName(false); if (!authorName) { var forced = ensureName(true); if (!forced) { throw new Error('Please enter your name first.'); } authorName = forced; } var payload = { post_slug: postSlug, post_url: window.location.href, author_name: authorName, content: content, }; if (parentId > 0) { payload.parent_id = parentId; } if (submitTarget) submitTarget.disabled = true; if (feedbackTarget) { feedbackTarget.textContent = 'Submitting...'; feedbackTarget.style.color = ''; } try { var response = await fetch('/api/post-comments', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Accept': 'application/json' }, body: JSON.stringify(payload) }); var data = await response.json().catch(function() { return {}; }); if (!response.ok || data.ok === false) { throw new Error((data && data.message) || 'Cannot submit comment.'); } await loadComments(1, 'replace'); return true; } finally { if (submitTarget) submitTarget.disabled = false; } } form.addEventListener('submit', async function(event) { event.preventDefault(); var content = String(contentEl.value || '').trim(); if (!content) { setFeedback('Please enter comment content.', true); return; } submitBtn.disabled = true; setFeedback('Submitting...'); try { await postComment(content, 0); contentEl.value = ''; setFeedback('Comment submitted.'); } catch (error) { setFeedback(error.message || 'Cannot submit comment.', true); } finally { submitBtn.disabled = false; } }); listEl.addEventListener('click', function(event) { var replyBtn = event.target.closest('.comment-item__reply-btn'); if (replyBtn) { var row = replyBtn.closest('.comment-item'); if (!row) return; var formEl = row.querySelector('.comment-item__reply-form'); if (!formEl) return; listEl.querySelectorAll('.comment-item__reply-form').forEach(function(f) { if (f !== formEl) f.classList.add('comment-box__hidden'); }); formEl.classList.remove('comment-box__hidden'); var input = formEl.querySelector('textarea'); if (input) input.focus(); return; } var cancelBtn = event.target.closest('.comment-item__reply-cancel'); if (cancelBtn) { var rf = cancelBtn.closest('.comment-item__reply-form'); if (!rf) return; rf.classList.add('comment-box__hidden'); var rInput = rf.querySelector('textarea'); var rFeedback = rf.querySelector('.comment-item__reply-feedback'); if (rInput) rInput.value = ''; if (rFeedback) rFeedback.textContent = ''; } }); listEl.addEventListener('submit', async function(event) { var replyForm = event.target.closest('.comment-item__reply-form'); if (!replyForm) return; event.preventDefault(); var row = replyForm.closest('.comment-item'); if (!row) return; var parentId = Number(row.getAttribute('data-comment-id') || 0); var input = replyForm.querySelector('textarea'); var submit = replyForm.querySelector('.comment-item__reply-submit'); var feedback = replyForm.querySelector('.comment-item__reply-feedback'); var replyText = String((input && input.value) || '').trim(); if (!replyText) { if (feedback) { feedback.textContent = 'Please enter reply content.'; feedback.style.color = '#dc2626'; } return; } try { await postComment(replyText, parentId, feedback, submit); // setFeedback('Reply submitted.'); } catch (error) { if (feedback) { feedback.textContent = error.message || 'Cannot submit reply.'; feedback.style.color = '#dc2626'; } } }); changeNameBtn.addEventListener('click', function() { ensureName(true); }); loadMoreBtn.addEventListener('click', async function() { if (currentPage >= lastPage) return; loadMoreBtn.disabled = true; try { await loadComments(currentPage + 1, 'prepend'); } catch (error) { setFeedback(error.message || 'Cannot load more comments.', true); } finally { loadMoreBtn.disabled = false; } }); ensureName(false); loadComments(1, 'replace').catch(function(error) { setFeedback(error.message || 'Cannot load comments.', true); }); })();