Skip to content

refactor: hoist StatusMessage out of PrintToZebraDialog render#16

Merged
u8array merged 1 commit into
mainfrom
refactor/extract-status-message
May 5, 2026
Merged

refactor: hoist StatusMessage out of PrintToZebraDialog render#16
u8array merged 1 commit into
mainfrom
refactor/extract-status-message

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 5, 2026

No description provided.

@u8array u8array merged commit 308f70a into main May 5, 2026
2 checks passed
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the PrintToZebraDialog.tsx file by moving the StatusMessage component out of the main component's scope to the top level. Feedback suggests enhancing the StatusMessage component to prevent rendering empty paragraph tags when the message is missing—which can disrupt layout in flex containers—and adding a role="status" attribute to improve accessibility for screen readers.

Comment on lines +19 to +26
function StatusMessage({ status }: { status: Status }) {
if (status.type === "idle" || status.type === "sending") return null;
return (
<p className={`font-mono text-[10px] ${status.type === "success" ? "text-green-400" : "text-red-400"}`}>
{status.message}
</p>
);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The StatusMessage component should handle cases where status.message might be missing or empty to avoid rendering an empty <p> tag. In a flex container with a gap, an empty child still occupies space and creates an unnecessary layout gap. Additionally, adding role="status" improves accessibility by ensuring status updates are announced to screen readers.

function StatusMessage({ status }: { status: Status }) {
  if (status.type === "idle" || status.type === "sending" || !status.message) return null;
  return (
    <p
      role="status"
      className={`font-mono text-[10px] ${status.type === "success" ? "text-green-400" : "text-red-400"}`}
    >
      {status.message}
    </p>
  );
}

@u8array u8array deleted the refactor/extract-status-message branch May 6, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant