UI边缘情况参考指南:分类测试与修复策略
UI edge cases: A reference guide
在AI辅助开发背景下,人工审查代码中的UI边缘情况变得尤为关键。一份综合性的参考指南将常见的UI缺陷分为内容驱动、状态驱动、输入驱动、布局响应式及系统环境五大类,为设计师和开发者提供了具体的测试方法、检测手段及设计修复方案。
针对内容驱动问题,需重点测试空状态(如零搜索结果)、极端文本长度(使用伪本地化或长字符串验证截断规则)、复数形式处理以及国际化适配(如RTL布局镜像和文本膨胀)。状态驱动方面,应模拟慢速网络以检查加载骨架屏、区分不同错误类型的恢复机制、优化乐观更新后的回滚体验,并处理会话过期及数据陈旧导致的冲突提示。
输入驱动环节强调键盘导航时的焦点可见性、禁用与只读状态的视觉区分、防止快速重复点击导致的竞态条件,以及复制粘贴带来的格式污染清理。布局响应式需覆盖极端视口尺寸、200%缩放下的排版完整性、动态内容引起的布局偏移(CLS)以及嵌套滚动容器的手势冲突。最后,系统环境测试包括深色模式与高对比度模式的兼容性、减少动画偏好的实现、字体加载闪烁(FOUT/FOIT)优化以及离线或弱网状态下的应用表现。该指南旨在通过标准化的检查流程,提升软件在复杂场景下的鲁棒性与用户体验。
A practical reference guide for catching UI edge cases before they ship — organized by category, with how to test, how to detect them in the wild, and how to design a fix. With examples.

Introduction
One day my colleague and I were at a workshop in a client’s office about agentic workflows in UI Design and Development when suddenly the client asked us a very good question.
“If we, designers and developers, are left to check the AI’s code for all the small but important edge cases it might miss — why don’t we give a document or a list of UI edge cases to the AI to begin with?”
Indeed a very good question, so my colleague and I tasked ourselves with finding a document like this so we could send it to our client.
But we couldn’t find anything that was generic enough to fit every client and specific enough to include all the little cases we saw everyday. Between us we have more than 15 years of UI Design and Development background.
We did find a few documents that had some of the information we needed as well as some that were industry-specific like documents for the Military, Governments, Medical or Telecom.
In the end I was tasked with writing a comprehensive document and sending it to the client for approval and it did end up giving the agentic workflow better results in terms of code generation.
So in the name of sharing, I give here the full document paraphrased in human language with some of the more technical code left out to keep it as generic and readable as possible.
1. Content-Driven
Empty states
This can happen when there’s no data to show yet, zero search results, empty inbox, empty list — screen looks broken or unfinished with no explanation.
To test, load the page with a brand-new account or a filtered view that returns nothing, or manually clear a list’s data source.
The solution is to design and implement a dedicated empty state — icon / illustration, one-line explanation, a clear next action (e.g., “No projects yet — Create one”).

Text length extremes
Long names or titles that break the layout (overflow, wrapping into other elements), very short or single-character values might look off-balance.
We can use pseudo-localization or seed test data with a deliberately long string (e.g., “Supercalifragilisticexpialidocious International Holdings LLC”) and a 1 or 2 character string in every text field, like “I” or “OK”.
We can solve this by defining truncation rules per component (single-line ellipsis vs. multi-line clamp vs. wrap) and set max-widths.

Long unbroken strings
URLs, emails, or IDs don’t wrap, causing horizontal overflow or breaking the container. A user might paste a long URL or a 40+ character token into any field that renders user content.
We should decide whether to truncate mid-string (common for hashes / emails) with an ellipsis in the middle, or just allow wrapping.

Pluralization and zero counts
Wordings like “1 items” or “0 item” can read as broken or unpolished. Some languages have more plural forms than English (Russian, Arabic).
Force counts of 0, 1, 2, and a large number through any relevant component, test with a locale that has more complex plural rules if you plan to localize.
To solve this we need to explicitly copy-write the 0, 1, and many states rather than assuming one template covers all of them. On the development side, we can use an i18n library with proper pluralization.

Localization / i18n
Translated text can run up to 40% longer (German, Finnish) or even run shorter, breaking fixed-width buttons and labels. RTL languages (Arabic, Hebrew) often need mirrored layouts while dates, numbers and currency formats vary.
We can pseudo-localize the UI (wrap strings with padding characters) to simulate expansion using a toggle with dir=”rtl” and browse the whole flow, try switching OS and browser locale when possible.
Design components with flexible widths, not fixed pixel widths for text containers, RTL “mirrored” variants for directional icons (arrows, chevrons and more) and “mirrored” interactions if relevant.
On the development side use logical CSS properties (margin-inline-start instead of margin-left) so RTL can be flipped automatically.

Missing media
Broken image links, users with no avatar, videos that failed to load — leaves a broken-image icon or an unintended blank space.
You can point an <img> src at a 404 URL (an address you know that doesn’t exist) to test this. Also test a user record with a null avatar field, a throttled network to successfully fail media loads.
Design a fallback state — initials-based avatar when image fails to load, or a generic placeholder image, a poster frame for a failed video.

2. State-Driven
Loading states
A blank screen or jarring pop-in while data loads — unclear if the app is frozen or if loading takes too long.
We can throttle network to “Slow 3G” in devtools and artificially delay API responses in a staging environment.
Design skeleton screens that match final content’s shape (not just generic spinners) for anything that takes >300ms and define a timeout state (“This is taking longer than usual”).

Error states
Network failures, validation errors, or partial failures (some data loaded, some didn’t) show up as a blank screen, console-only error, or generic “Something went wrong.”
Kill the network mid-request, mock a 500 / 403 / timeout response, simulate a request where only some of several parallel calls fail.
We should design distinct states per error type (network vs. permission vs. validation) with actionable recovery (a retry button, send bug report etc).

Interim / optimistic states
The gap between user action and server confirmation is either invisible (user might be unsure if it worked) or the UI update is later reverted, thus confusing the user.
We can add artificial latency and watch what the UI displays between click and response, we can force the server call to fail after an optimistic update to see the rollback behavior. Review any “like / save / delete” style interaction.
Define a clear pending visual, such as: subtle dimming, spinner on a specific element (not the whole page) and a clear rollback / error treatment if it fails / succeeds.

Permission / auth states
Logged-out views, session expiring mid-action, or insufficient permissions leads to silent failures or confusing redirects.
We can expire a session token manually and attempt an action, log in as a lower-permission role and attempt a restricted action, test deep-linking to a protected page while logged out.
Design a “session expired” interstitial that preserves the user’s in-progress work where possible, also design disabled / hidden variants for restricted actions with an explanation on hover or on tap.

Stale data
User might leave a tab open for hours, underlying data changes (deleted by someone else or otherwise updated elsewhere) and the UI still reflects the older state, leading to conflicting edits.
To test this — try to open the same record in two sessions, edit in one, then act on the other without refreshing.
We should design a “this has changed” banner with a refresh or merge actions rather than silently overwriting the tab, which can be jarring.

3. Input-Driven
Focus states
Keyboard-only users can’t tell what’s in focus. Focus can get trapped or lost when opening / closing modals or menus.
Try unplugging the mouse and navigate the entire flow with Tab / Shift+Tab / Enter / Space / Escape only.
Design a visible, high-contrast focus ring as a first-class state for every interactive element (don’t rely on browser defaults, but don’t remove it completely either).

Disabled / readonly variations
Disabled and readonly states might look identical, or aren’t visually distinguishable enough from enabled states, this can confuse users about why they can’t interact with some elements.
Try Placing a disabled, readonly, and enabled version of the same component side by side, or next to a simliar looking component, and see if a new user can tell them apart without any documentation (for example a primary disabled button next to an enabled secondary button).
Give the disabled and readonly states a distinct, documented visual treatment (for example: disabled = grayed + no cursor change. Readonly = normal color + lock icon).

Rapid / repeated input
Users might double-click a submit button and it shouldn’t fire duplicate requests (double charge, duplicate record, etc.), spamming a button or rapid resize / scroll causes jank or race conditions.
Try rapidly double-click and triple-click every button, hold down a resize handle and drag erratically, scroll-flick a long list repeatedly.
Show an immediate disabled / loading / read-only state on the button or input field the instant it was clicked.

Copy-paste
A pasted text can carry unexpected formatting, emojis, or control characters that break layout, validation, or storage.
Try to copy rich text from a Word doc or a webpage and paste it into every text input or text area. Paste emoji-heavy text and right-to-left text. Paste a string with null bytes or control characters.
Decide whether inputs even should accept formatting (a rich text field) or strip it (a plain text field) and be consistent per field type or style.
4. Layout / Responsive
Extreme viewport sizes
Very narrow screens (folded phones, for example) or very wide monitors (ultrawide, 3440px+) can break layouts designed for a “typical” resolution range.
Resize the browser window to its minimum and to full ultrawide width, you can use devtools device emulation for specific devices or screen sizes.
Design with min-width / max-width content in mind, don’t let a single-column layout stretch to a full-width column on an ultrawide display. Don’t let content collapse below a usable minimum either.

Zoom levels
Try zoom the browser to 200% or use OS text-scaling to break the layout, this can create overlapping texts and cut-off buttons.
Zoom browser to 200% (a WCAG requirement) and navigate the full flow. Increase or decrease OS-level text size setting.
Design with relative units in mind so text scaling doesn’t require pixel-perfect fixed layouts, otherwise near-sighted users may be unable to use your website.

Dynamic content changing dimensions
A component resizing based on content (for example: an accordion, a comment with a long reply) can push neighboring elements around unexpectedly, causing a layout shift.
Try to trigger the resize (expand accordion, load async content, change dynamic content) and watch for neighboring elements jumping, you can also check Lighthouse’s Cumulative Layout Shift score.
To accomodate this, please reserve space or use smooth height transitions rather than instant jumps. Consider whether the expanding element should overlay instead of pushing the content.

Nested scroll containers
Scroll-within-scroll creates ambiguous scroll targeting (users might scroll the page when they meant scrolling the inner panel, or vice versa).
Sticky elements can overlap or conflict, horizontally-scrollable components (carousels, tables) nested in a vertically-scrolling page can hijack diagonal trackpad / touch gestures, or unintentionally introduce page-level horizontal scrolling if content overflows without being contained.
We can scroll with our cursor at the boundary between inner and outer scrolling areas. We can test using a trackpad, a mouse wheel, and touch input separately (they can behave differently).
Also check for an unexpected horizontal scrollbar on the page itself by resizing the viewport narrower than the widest nested element.
Minimize nested scroll where possible. If necessary, give the inner scroll area a clear visual boundary so users can know which scroll will be captured. Avoid mixing scroll axes in adjacent / nested regions where possible.

Safe areas
Take into consideration notches, browser chrome, and virtual keyboards covering content or inputs, especially on mobile.
Test on an actual notched device (or simulator) in both orientations, also focus a text input near the bottom of the screen and check if the keyboard covers it or shifting the view to reveal it.
Try to keep critical content and actions out of the extreme edges. Design for a keyboard-visible state on forms when possible.

5. System / Environment
Dark mode / forced-colors / high contrast
Custom-styled components (checkboxes, radio buttons, focus rings) lose their custom styling or become invisible in forced-colors / high-contrast modes. Dark mode might reveal hardcoded colors that don’t adapt.
Toggle OS-level dark mode and Windows High Contrast Mode. Test with devtools prefers-color-scheme: dark / light.
Define a full dark-mode palette (not just an inverted light mode) and verify contrast ratios in both modes.

Reduced motion preference
Some users have stated preference for reduced motion and they still get full animations, which can cause discomfort or eye strain.
Try to enable “Reduce Motion” in OS accessibility settings and revisit all animated interactions in your site, does it still animate or do you see a fallback instead?
We should design a reduced-motion variant for key animations like cross-fading instead of slides and zooms, or instant state changes instead of complex movement.

Font-loading flash (FOUT / FOIT)
FOUT is the Flash of unstyled text and FOIT is the Flash of invisible text, both can happen while custom web fonts load, often times with a layout shift when the font swaps.
Throttle your network in devtools and reload the page. Compare fallback font metrics to the final font. Lighthouse flags font-display issues and layout shift from font swap.
We can try and choose a fallback font with similar x-height / width to the custom font to minimize the layout shift, or we can choose to hide the text itself until the font loads.

Offline / flaky connectivity
When a user is on a flaky network, the app might appear frozen or throws unhandled errors when the network drops or is intermittent.
Please use the devtools to simulate “Offline” mid-session. Use a network-throttling proxy to simulate packet loss or a flaky connection.
Design an offline banner / indicator and, if feasible, an offline-capable mode (view cached data, queue actions, local host etc).

Closing thoughts
I hope this list can be the bare-minimum standard of UI edge cases that are checked and taken care of, from localization to error states to offline mode, there’s no reason to leave them out anymore.
Next year I’m sure we’ll have more edge cases that will pop up once those are already fixed, I have high hopes for this industry that with the emergence of AI the standard for good software will only get higher.
If this list made you, or your AI, spit out more usable code or a better thought out product overall, please share this article online.
Thanks for reading, and I’d love to hear your experience in the comments, also if I missed any edge cases — please tell me and I’ll roll it into the next version of this article.
Sources
Apple Human Interface Guidelines — Patterns
Thinking like a developer, part II: design the edge cases
Edge Cases in UX/UI Explained
UX Edge Cases
Designing for Edge Cases: UX That Works When Things Go Wrong
20 Edge Case Examples in Software That Product Teams Miss
原作者保留版权;来源:UX Collective。本站维护者确认获准转载,非公共领域或开放许可证声明。 原文来源(转载授权由站点维护者确认) · 中文译文由 CxHub 客户体验社区生成,并非官方译文。
来源:UX Collective · uxdesign.cc