openedx / openedx/paragon

`Truncate` component relies on `elementType` instead of `as` (props API inconsistency)

Open
#2,986 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
140
Forks
100
Avg merge
1h 3m
Merged PRs (30d)
30

Description

Improvements

Any component that allows consumers to override its underlying DOM element (e.g., div, span) should rely on an as prop for consistency with the majority of Paragon components (given most rely on react-bootstrap).

The Truncate component uses an elementType component instead of as. At least one engineer assumed as prop would work, and had to rely on the documentation to learner that Truncate uses elementType instead.

Given one of the goals of Paragon is to provide a reasonably consistent props API across components, we should ensure that any component that allows consumers to override its underlying DOM element relies on an as prop.

### Tasks
- [ ] Deprecate the `elementType` prop (`withDeprecatedProps`) in `Truncate` component.
- [ ] Introduce `as` prop instead to replace `elementType` (consistent with other components).
- [ ] Identify any other Paragon components that support consumers overriding element types, ensuring they also use `as` instead of an inconsistent prop name.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Truncate component and its documentation to understand the current elementType API and how comparable Paragon components expose as. Inspect other components that let consumers override their underlying element type. Done means elementType is deprecated, as replaces it consistently in Truncate, and any other inconsistent components are identified and updated.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.