Repository navigation
feat(app): add InlineNameInput as the one way to name objects #3278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5f58688
feat(app): add InlineNameInput as the one way to name objects
elizabetdev 82d0cbe
feat(app): use InlineNameInput in the chart editor and size it xs to md
elizabetdev 530b529
revert(app): keep the chart editor's existing name field for now
elizabetdev 4de1aee
fix(app): match saved search title spacing to the dashboard header
elizabetdev 4f521cc
fix(app): keep a renamed title on screen until the save lands
elizabetdev 4be9c6e
fix(app): give named headings the object's name
elizabetdev d6512fa
fix(app): read the dashboard name from the title field in e2e
elizabetdev 9fca5a7
Merge branch 'main' into elizabet/inline-name-field
kodiakhq[bot] 6a57642
Merge branch 'main' into elizabet/inline-name-field
kodiakhq[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| --- | ||
| '@hyperdx/app': patch | ||
| --- | ||
|
|
||
| feat: rename dashboards and saved searches by clicking the title instead of a | ||
| pencil button | ||
|
|
||
| The name is now edited in place: Enter or clicking away saves, Escape reverts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| --- | ||
| name: naming-objects | ||
| description: | ||
| Name user-created objects (dashboards, saved searches, tiles, alerts) with the | ||
| shared InlineNameInput. Use when adding or changing the place where a user | ||
| names or renames something, building an editor or page header that shows an | ||
| object's name, or when tempted to add a pencil edit button, a "Name" field in | ||
| a save modal, or a bordered name TextInput. | ||
| --- | ||
|
|
||
| # Naming objects | ||
|
|
||
| Read **`agent_docs/naming_objects.md`** before changing how something is named. | ||
| It is the source of truth; this skill is the short version. | ||
|
|
||
| ## Quick rules | ||
|
|
||
| 1. Use `InlineNameInput` / `InlineNameInputControlled` from | ||
| `@/components/InlineNameInput/InlineNameInput`. Never build a separate | ||
| click-to-edit title, pencil button, or "Save name" button. | ||
| 2. **Saved object shown on its page** → `InlineNameInput` with `onCommit`. Enter | ||
| or blur saves immediately; Escape and empty names revert. | ||
| 3. **Draft in an editor** → `InlineNameInputControlled` with the form's | ||
| `control`. The name saves with the editor's save button. | ||
| 4. Sizes are `xs`, `sm`, `md` only. Page titles use `size="md"` with | ||
| `headingLevel={3}`. Editor headers use `size="sm"` (default). Compact rows | ||
| use `size="xs"`. | ||
| 5. Always set `aria-label` ("Dashboard name") and an "Untitled …" placeholder in | ||
| sentence case ("Untitled tile"). | ||
| 6. Don't ask for a name inside a save modal. Name inline, then save. | ||
| 7. In tests, assert the name with `toHaveValue`. In E2E, `fill()` then press | ||
| Enter. | ||
|
|
||
| ## Workflow | ||
|
|
||
| 1. Read `agent_docs/naming_objects.md`. | ||
| 2. Look at the reference usages: `DBDashboardPage.tsx` (dashboard name) and | ||
| `DBSearchPage.tsx` (saved search name). | ||
| 3. Check the stories in Storybook under **Components/InlineNameInput**. | ||
| 4. Update E2E page objects that read the name as text. | ||
| 5. Run `yarn lint:fix` in the repo root. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| # Naming objects | ||
|
|
||
| Every user-named object (dashboard, saved search, dashboard tile, alert, and so | ||
| on) gets its name through one control: `InlineNameInput`. It looks like plain | ||
| title text until you hover or click it, then edits in place. There is no pencil | ||
| button, no double-click, no separate "Save name" button, and no naming step | ||
| inside a save modal. | ||
|
|
||
| ```tsx | ||
| import { | ||
| InlineNameInput, | ||
| InlineNameInputControlled, | ||
| } from '@/components/InlineNameInput/InlineNameInput'; | ||
| ``` | ||
|
|
||
| ## Pick the variant by how the object is saved | ||
|
|
||
| | The object is... | Use | When the name is saved | | ||
| | ------------------------------------------------------------------------ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| | Already saved, and the page shows it (dashboard page, saved search page) | `InlineNameInput` with `onCommit` | Enter or blur commits. The typed name stays until `value` updates. Return a rejected promise from `onCommit` to revert it. Escape reverts, and an empty or unchanged name reverts. | | ||
| | A draft in an editor (tile editor, new chart, new saved search) | `InlineNameInputControlled` with the form's `control` | With the rest of the form, when the user presses the editor's save button. | | ||
|
|
||
| A rename on a saved object is an arrangement change, like moving a tile, so it | ||
| saves without a confirmation. A name on a draft is part of the draft's content, | ||
| so it waits for the explicit save. | ||
|
|
||
| ## Size and placement | ||
|
|
||
| Sizes go from `xs` to `md`. Don't add larger ones. | ||
|
|
||
| - `size="md"`: the page title, top-left of the page body under the breadcrumbs. | ||
| Pass `headingLevel` so the name is still the page heading for screen readers | ||
| and `getByRole('heading')`. Use `headingLevel={3}` to match the existing | ||
| dashboard and saved search pages. | ||
| - `size="sm"` (default): editor headers, next to the close button and before the | ||
| editor's actions. | ||
| - `size="xs"`: compact rows, such as a name inside a dense form or list. | ||
|
|
||
| ## Copy | ||
|
|
||
| - `aria-label` is required because there is no visible label: "Dashboard name", | ||
| "Saved search name", "Tile name". | ||
| - The placeholder is "Untitled" plus the object type in sentence case: "Untitled | ||
| dashboard", "Untitled search", "Untitled tile". Don't use "Name". | ||
| - Don't add a "Name" label or helper text next to the field. | ||
|
|
||
| ## Examples | ||
|
|
||
| Saved object, saves on commit: | ||
|
|
||
| ```tsx | ||
| <InlineNameInput | ||
| value={dashboard.name} | ||
| onCommit={name => setDashboard({ ...dashboard, name })} | ||
| placeholder="Untitled dashboard" | ||
| aria-label="Dashboard name" | ||
| size="md" | ||
| headingLevel={3} | ||
| data-testid="dashboard-name-input" | ||
| /> | ||
| ``` | ||
|
|
||
| Draft, saves with the form: | ||
|
|
||
| ```tsx | ||
| <InlineNameInputControlled | ||
| control={control} | ||
| name="name" | ||
| size="sm" | ||
| placeholder="Untitled tile" | ||
| aria-label="Tile name" | ||
| data-testid="chart-name-input" | ||
| /> | ||
| ``` | ||
|
|
||
| ## Don't | ||
|
|
||
| - Don't build a click-to-edit title with a pencil `ActionIcon` and an edit mode. | ||
| That was `EditablePageName`, which this replaces. | ||
| - Don't use a bordered `TextInput` for an object's own name in a page or editor | ||
| header. | ||
| - Don't ask for the name in a modal before saving. Name inline, then save. | ||
| - Don't show a success toast for a rename. Show an error toast if the save | ||
| fails. | ||
|
|
||
| ## Testing | ||
|
|
||
| - The field is a textbox, so assert with `toHaveValue`, not `toHaveText`. | ||
| - To rename in E2E: `fill()` the input, then press Enter. See | ||
| `DashboardPage.renameDashboard` in `packages/app/tests/e2e/page-objects/`. | ||
| - Storybook: **Components/InlineNameInput** shows both variants and sizes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 minor — Renaming before the dashboard loads leaves a name on screen that was never saved
When
dashboardis still undefined (loading, or the id is not found),onCommitreturnsundefined.InlineNameInputthen keepspendingset to the typed name untilvaluechanges, so the title shows a name that was never saved. This is the opposite of the 'visibly reverts' behaviour the component promises. ReturnPromise.reject(new Error('Dashboard not loaded'))here, or make the inputreadOnlyuntildashboardexists.Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond