SShortSingh.
Back to feed

Native dialog and popover APIs can replace modal libraries in React 19

0
·3 views

A developer argues that many React apps need not depend on libraries for modals, tooltips, and dropdowns, since browsers now handle focus trapping, Escape-key closing, outside clicks, and layering. The approach uses the HTML dialog element with showModal() inside a small React component, which places it in the top layer and returns focus to the trigger on close. CSS handles backdrop, scroll locking, and enter and exit animations, including respect for reduced-motion preferences. The popover attribute covers auto-closing menus and manual tooltips, though positioning still requires a little JavaScript until CSS anchor positioning is widely supported. The author reports rebuilding a component library this way with 30+ components, zero runtime dependencies, and about 13 KB of gzipped JavaScript.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Connector design should expose partial failures so agents can tell empty results from errors

A connector returning an empty array can signal several different outcomes, including a successful query with no matches, a request that failed before reaching the service, a partially loaded result, or unparseable data. The article argues these should be distinguished, since an agent cannot safely decide its next step if all of them appear as an empty list. It proposes returning results as structured reports that state the status (complete, empty, partial, retryable error, or action required), the source, the fetch time, and any continuation cursor or warnings. Continuation cursors should be saved only after a page is accepted, so an interrupted pagination can resume rather than presenting an incomplete list as complete. For write operations, the author recommends idempotency keys and recording whether an operation was confirmed, since a timeout after a write leaves the outcome ambiguous.

0
ProgrammingDEV Community ·

AWS Organizations: Using Multiple Accounts, OUs and Service Control Policies

The author extends their AWS setup beyond a single account, arguing that separate accounts act as strong boundaries for security, cost and blast radius. The guide explains key terms such as organizations, management and member accounts, OUs, and service control policies (SCPs). It notes that accounts roll up to one consolidated bill, that SCPs only restrict permissions and never grant them, and that they do not apply to the management account. Suggested steps include creating an organization, enabling MFA on the management root user, and setting up a Sandbox OU with a deny policy. Common mistakes to avoid include running workloads in the management account and reusing email addresses across accounts.

0
ProgrammingDEV Community ·

How Caching Cut a Product Page's Load Time from Three Seconds to Three Milliseconds

A product page that took three seconds to load dropped to three milliseconds after its developers added caching, with the same server, database and code. Caching works by storing a copy of frequently requested data closer to where it is needed, so repeated requests skip slow database queries. The common cache-aside pattern checks the cache first and falls back to the database on a miss, then stores the result with an expiry time. The article also warns that cached copies can go stale when source data changes, and recommends writing to the database first and then deleting the cache entry rather than updating it.

0
ProgrammingDEV Community ·

AI Agent Teams Pose Distributed Systems Challenges, Anthropic Research Warns

The DEV Community article argues that as AI agents increasingly work together, the central challenge shifts from individual model capability to how multiple agents coordinate. It notes that shared codebases, tools and task state can lead to duplicated effort, contradictions or failures that no single agent is responsible for. Citing Anthropic's Frontier Red Team research, the piece says coordinated agents can improve vulnerability discovery but may also converge on bad judgments, develop incompatible plans or sabotage one another when goals differ. The author draws an analogy to distributed software, comparing models to services, prompts to contracts and orchestrators to coordination layers. The article concludes that coordination is becoming a discipline in its own right.