Skip to content
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

Page: Add inline rename functionality #68828

Merged
merged 26 commits into from
May 31, 2023
Merged

Page: Add inline rename functionality #68828

merged 26 commits into from
May 31, 2023

Conversation

ashharrison90
Copy link
Contributor

@ashharrison90 ashharrison90 commented May 22, 2023

What is this feature?

  • creates a new EditableTitle component
  • exposes an onEditTitle prop on the Page component
  • when onEditTitle is present, use EditableTitle as the page title to provide inline rename capabilities

Why do we need this feature?

  • better UX for individual item pages

Who is this feature for?

  • everyone!

Which issue(s) does this PR fix?:

Fixes #68070

Special notes for your reviewer:

Please check that:

  • It works as expected from a user's perspective.
  • If this is a pre-GA feature, it is behind a feature toggle.
  • The docs are updated, and if this is a notable improvement, it's added to our What's New doc.

@ashharrison90 ashharrison90 added area/navigation no-backport Skip backport of PR no-changelog Skip including change in changelog/release notes area/manage-dashboards labels May 22, 2023
@ashharrison90 ashharrison90 added this to the 10.1.x milestone May 22, 2023
@ashharrison90 ashharrison90 self-assigned this May 22, 2023
@ashharrison90 ashharrison90 requested a review from joshhunt May 22, 2023 13:57
@ashharrison90 ashharrison90 marked this pull request as ready for review May 26, 2023 12:04
@ashharrison90 ashharrison90 requested a review from a team as a code owner May 26, 2023 12:04
@ashharrison90 ashharrison90 requested review from L-M-K-B and removed request for a team May 26, 2023 12:04
@@ -95,7 +96,7 @@ export function AutoSaveField<T = string>(props: Props<T>) {
disabled={disabled}
error={error || (fieldState.showError && saveErrorMessage)}
ref={fieldRef}
className={styles.widthFitContent}
className={classNames(styles.widthFitContent, restProps.className)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😬 Not enthusiastic about supporting class name prop for new UI components.

I guess this is so we can make the input large to match the H1.... do we want/need a new lg/xl size for the text box instead? @eledobleefe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, do you even use this component here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah I didn't use Autosavefield in the end so can remove this change 👌

@tskarhed
Copy link
Contributor

tskarhed commented May 31, 2023

The time it takes for the Input to disappear after I've blurred or pressed enter feels a little bit clunky. I would prefer the frontend would directly flip to the edited title, and then flip back and display an error if it fails.

@ashharrison90
Copy link
Contributor Author

@tskarhed done 👍 you're right, it feels much snappier 😍

Copy link
Contributor

@joshhunt joshhunt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work. This is thoughly developed, tested, and thought about - well done 👏🏻

I'm a little bit uncertain on the interaction, especially with how it's just.... saved automatically without much feedback on blur, but happy to defer to others and see what it's like in practice.

(just the two small comments)

Comment on lines 17 to 18
const [isEditing, setIsEditing] = useState(false);
const [isEditInProgress, setIsEditInProgress] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found these two names pretty confusing. Maybe we could rename isEditInProgress to isLoading?

Comment on lines 54 to 59
{/*
use localValue if it exists
this is to prevent the title from flickering back to the old value after the user has edited
caused by the delay between the save completing and the new value being refetched
*/}
<H1 truncate>{localValue ?? value}</H1>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's an iffy bit here where the parent cannot change the value prop after its ever been edited?

I think this is an instance where we want to react to changes in the value prop and sync it to state.

const [localValue, setLocalValue] = useState(value);
useEffect(() => {
  setLocalValue(value);
}, [value])

(this should not cause a re-render on first mount as the value doesn't change)

@joshhunt
Copy link
Contributor

Also, long title that wraps pushes the page actions down to a new line

image

but then when you hit edit the actions wrap back up

image

@ashharrison90
Copy link
Contributor Author

@joshhunt applied your changes and adjusted the css for the title - should be more consistent now.

@ashharrison90 ashharrison90 changed the title Nested folders: Add inline rename functionality Page: Add inline rename functionality May 31, 2023
@ashharrison90 ashharrison90 added add to changelog and removed no-changelog Skip including change in changelog/release notes labels May 31, 2023
@ashharrison90 ashharrison90 merged commit 10adebd into main May 31, 2023
@ashharrison90 ashharrison90 deleted the ash/inline-rename branch May 31, 2023 16:03
@ricky-undeadcoders ricky-undeadcoders modified the milestones: 10.1.x, 10.1.0 Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename folder
5 participants