SShortSingh.
Back to feed

HTML's native <dialog> element replaces focus traps, ARIA hacks, and backdrop divs

0
·2 views

A DEV Community article highlights how developers commonly build modals using custom divs loaded with ARIA attributes, focus-trap libraries, and manual keyboard listeners — work the browser can handle natively. The HTML <dialog> element, opened via showModal(), automatically manages focus trapping, Escape-to-close behavior, and ARIA roles without any third-party dependencies. It also renders a built-in backdrop styled via the ::backdrop pseudo-element, eliminating the need for manually positioned overlay divs. Developers can add entry and exit animations using @starting-style and CSS transitions, with a small JavaScript fallback for older browsers. The article concludes that adopting <dialog> reduces boilerplate significantly while improving accessibility out of the box.

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 ·

Apicurio Registry's three prompt renderers use different regex engines, causing inconsistent output

A technical analysis of Apicurio Registry's main branch reveals that a single stored PROMPT_TEMPLATE artifact is processed by three independent code surfaces: a REST renderer, an MCP converter, and a write-time validator. Each component uses its own regular expression to parse template variables, meaning they do not share a common rendering engine or call one another. As a result, a template like '{{ name }}' with added whitespace, dots, or conditional blocks can produce three different outputs from the same stored content. For example, the REST renderer trims whitespace and accepts loose syntax, while the validator applies a stricter pattern that may not recognise the same variables. Developers building UI playgrounds or new clients on top of prompt rendering must identify which of the three surfaces their code actually targets to avoid inconsistent results.

0
ProgrammingDEV Community ·

GSTIN Checksum Validation Explained: What It Catches and What It Misses

Every Indian GST invoice contains a 15-character GSTIN, whose final character is a checksum computed from the preceding 14 using alternating weights and a 36-character alphabet, similar to the ISO 7064 MOD 37-36 algorithm. Developers often rely solely on regex pattern matching to validate GSTINs, but this only verifies the string's format, not its authenticity. Implementing a checksum verification step — requiring no API call or external dependency — can cheaply filter out a large share of typos and malformed inputs before any network request is made. However, a checksum-valid GSTIN may still belong to an unregistered, cancelled, or entirely fictitious entity, meaning live verification via the GST network remains necessary for full validation. A REST API service called gstinapi.in offers real-time GSTIN lookups returning legal name, registration status, and address, with 100 free monthly queries available without a credit card.

0
ProgrammingDEV Community ·

llms.txt: The Simple File Helping AI Systems Better Understand Your Website

In December 2024, fast.ai founder Jeremy Howard proposed a new open standard called llms.txt — a Markdown-formatted file placed in a website's root directory to help AI systems understand a site's structure and key content. Analogous to robots.txt for search engines, the file provides AI tools with a concise, structured overview including page links, company descriptions, and optional usage guidance. The standard has gained backing from major platforms such as Reddit, Cloudflare, Akamai, and Creative Commons, and is supported by AI tools including Claude and Perplexity. Adopting the standard is optional and takes only a few minutes to implement, with no rebuilding required for platforms like Next.js or WordPress. Importantly, llms.txt acts as a pointer to valuable content rather than a replacement for it, and its presence signals that a company is proactively managing how AI systems perceive it.

0
ProgrammingDEV Community ·

Seven Lessons From Migrating a Multi-Tenant SaaS Dashboard From MUI to Shadcn

An engineering team replaced Material UI with Radix and Shadcn across a multi-tenant SaaS dashboard over the past quarter, reducing bundle size and simplifying their design system. The migration involved six teams and dozens of production components, and proved far messier than typical online tutorials suggest. Key issues included focus management differences in dialogs, incorrect component mappings such as using Drawer instead of Sheet, and Radix portal rendering bugs caused by CSS transform properties on ancestor elements. The team also had to build a custom multi-select and async-select solution on top of Radix Popover and Command, since Radix Select lacks native async and multi-value support. Their main takeaway was that a real-world migration rarely achieves full coverage, and maintaining clear escape hatches for complex legacy components is more practical than forcing a complete rewrite.