# Disabled State Standards

## Objective

Make unavailable actions obvious and explainable rather than dim and mysterious.

A house rule for when a control may be disabled at all, how it looks, and how the reason reaches the user.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Go through every disabled control in the app and classify why it is disabled: missing input, missing permission, wrong record state, or a request already in flight. Each of those calls for different treatment and different copy.
2. Prefer letting the user act and then explaining the failure. A control disabled with no explanation forces the user to guess, and guessing usually ends with them leaving the screen.
3. Where a control genuinely must stay unavailable, attach the reason to it in a form reachable by pointer, by keyboard focus, and by touch. A tooltip that appears only on hover is invisible to most of the people who need it.
4. Use the platform's native disabled semantics where the control needs no explanation, so assistive technology reports the state correctly, and fall back to a control that looks unavailable but remains focusable only where the user must reach it to read why.
5. Do not fix the contrast problem by darkening disabled text until it stops looking disabled. Keep the text legible and carry the unavailability in the fill and border instead. When a control may be disabled is owned here; its exact rest, hover, and focus appearance is enumerated by the Hover Active Focus Checklist.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- A natively disabled control cannot receive focus, so any explanation attached to it is unreachable by keyboard. If the reason matters, the control has to stay focusable and be marked unavailable instead.
- The most consequential disabled control on a screen — the submit, the invite, the upgrade — is the one users are most often blocked by and the one that most often carries no explanation at all.
- Disabling submit until a form is valid hides which field is wrong. Allow the submit and surface the errors, particularly on long forms where the offending field is off screen.
- Disabled text still has to be read. Grey on grey at a contrast level nobody can meet is a legibility failure rather than a state.
- A control disabled because a request is in flight needs a pending treatment distinct from one disabled for lack of permission: the first resolves on its own, the second never will.
- Permissions and record states change mid-session, so a control disabled at load must re-evaluate rather than staying stale until the next reload.
- Disabled items inside a menu or toolbar must not be silently skipped by keyboard navigation with no indication that they exist.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] Every disabled control in the app has a classified reason behind it.
- [ ] The reason a control is unavailable is reachable by pointer, keyboard, and touch.
- [ ] No form submission is blocked by a disabled button where inline validation would explain the problem better.
- [ ] Native disabled semantics are used where no explanation is needed, and focusable unavailable states where one is.
- [ ] Disabled text remains legible and the state is carried by more than text colour.
- [ ] In-flight, no-permission, and wrong-state reasons are visually distinguishable.
- [ ] Disabled states re-evaluate when permissions or record state change during a session.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
