Content
View differences
Updated by Alexander Coles 10 days ago
Two independent implementations handle truncated/expandable text using Primer's `HiddenTextExpander`: Primer's `HiddenTextExpander` ([edge Lookbook docs](https://qa.openproject-edge.com/lookbook/inspect/primer/alpha/hidden_text_expander/playground)) is currently used in at least two different ways:
1. **Inline expansion** — `OpPrimer::ExpandableTextComponent` + **additional content is expanded inline**: on the Permissions Report and Workflows pages using the Stimulus `TruncationController`
- Horizontal truncation (CSS ellipsis via `Primer::Beta::Truncate`)
- Text expands/collapses
1. Example: [https://qa.openproject-edge.com/admin/roles/report](https://qa.openproject-edge.com/admin/roles/report)
2. Example: [https://qa.openproject-edge.com/workflows/7/edit](https://qa.openproject-edge.com/workflows/7/edit)
2. **additional content is shown in place
- Used on: [Permissions Report](https://qa.openproject-edge.com/admin/roles/report), [Workflows](https://qa.openproject-edge.com/workflows/7/edit)
2. **Dialog expansion** — `OpenProject::Common::AttributeComponent` + Stimulus `AttributeController`
- Vertical truncation (`max-height` + `overflow: hidden`)
- Opens a `Primer::Alpha::Dialog` with full text
- Used for dialog**: where Project Attributes
These share the same core problem — detect truncation, show an expander — but differ on two orthogonal axes:
- **Truncation direction:** horizontal (single-line) vs vertical (multi-line are rendered via `line-clamp`)
- **Expansion mode:** inline (toggle in place) vs dialog (open modal)
### Scope
1. **Unify `OpenProject::Common::AttributeComponent` and Stimulus controllers** — fold `AttributeController` into `TruncationController` with `mode` (horizontal/vertical) and `inline` (true/false) values
2. **Extend `ExpandableTextComponent`** — support all four combinations of truncation direction × expansion mode
3. **Refactor `AttributeComponent`** — compose `ExpandableTextComponent` instead of managing truncation markup directly
4. **Document
These patterns should be documented in Lookbook** — previews for all modes + docs page
### Open question for reviewers
The old `AttributeController` had a "text hider" overlay that masked truncated content behind a solid background (needed because the expand button was absolutely positioned over the text). With the new flex layout and `line-clamp`, this overlay should be unnecessary. Flagged for review. Lookbook.
### Screenshots #### **Example 1**
#### Example 1 (Permissions Report — horizontal inline)
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/921290/content"><img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/921291/content">
#### Example 2 (Project Attributes — vertical dialog)
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/921293/content"><img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/921292/content">
### Related Scope (tbd)
- #75275 — extracted `ExpandableTextComponent` Optionally, we may want to consider (or create separate work packages for):
* extracting one ~~or both~~ implementations into a higher-level component, e.g. `OpPrimer::ExpandableText` (done as part of <mention class="mention" data-id="75275" data-type="work_package" data-text="#75275">#75275</mention> )
* investigating whether any `TruncationController` and fixed ellipsis alignment (merged) `AttributesController` implementation can be shared/DRY'ed up.
* evaiuate accessibility of both approaches.
<br>
1. **Inline expansion** — `OpPrimer::ExpandableTextComponent` +
- Horizontal truncation (CSS ellipsis via `Primer::Beta::Truncate`)
- Text expands/collapses
1. Example: [https://qa.openproject-edge.com/admin/roles/report](https://qa.openproject-edge.com/admin/roles/report)
2. Example: [https://qa.openproject-edge.com/workflows/7/edit](https://qa.openproject-edge.com/workflows/7/edit)
2. **additional content is shown
- Used on: [Permissions Report](https://qa.openproject-edge.com/admin/roles/report), [Workflows](https://qa.openproject-edge.com/workflows/7/edit)
2. **Dialog expansion** — `OpenProject::Common::AttributeComponent` + Stimulus `AttributeController`
- Vertical truncation (`max-height` + `overflow: hidden`)
- Opens a `Primer::Alpha::Dialog` with full text
- Used for
These share the same core problem — detect truncation, show an expander — but differ on two orthogonal axes:
- **Truncation direction:** horizontal (single-line) vs vertical (multi-line
- **Expansion mode:** inline (toggle in place) vs dialog (open modal)
### Scope
1. **Unify
2. **Extend `ExpandableTextComponent`** — support all four combinations of truncation direction × expansion mode
3. **Refactor `AttributeComponent`** — compose `ExpandableTextComponent` instead of managing truncation markup directly
4. **Document
These patterns should be documented
### Open question for reviewers
The old `AttributeController` had a "text hider" overlay that masked truncated content behind a solid background (needed because the expand button was absolutely positioned over the text). With the new flex layout and `line-clamp`, this overlay should be unnecessary. Flagged for review.
### Screenshots
#### Example 1 (Permissions Report — horizontal inline)
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/921290/content"><img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/921291/content">
#### Example 2 (Project Attributes — vertical dialog)
<img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/921293/content"><img class="op-uc-image op-uc-image_inline" src="/api/v3/attachments/921292/content">
### Related
- #75275 — extracted `ExpandableTextComponent`
* extracting one ~~or both~~ implementations into a higher-level component, e.g. `OpPrimer::ExpandableText` (done as part of <mention class="mention" data-id="75275" data-type="work_package" data-text="#75275">#75275</mention> )
* investigating whether any `TruncationController`
* evaiuate accessibility of both approaches.
<br>