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

Add a "new record" button at the bottom of grid and detail views #1431

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

manuhabitela
Copy link
Collaborator

@manuhabitela manuhabitela commented Feb 7, 2025

Context

See #366.

Lucie's mockups: https://www.figma.com/design/wcpetFt6aOKzTszcvPPWLQ/%5B05%2F24%5D-Grist-Design?node-id=3744-62552&t=MhknMbyFwd1RAc9n-0

Proposed solution

Very early wip that lead me to some questioning:

Conditions to show the button

The show/hide condition of the button certainly needs refinement. I mostly rely on the view's enableAddRow boolean, and show the button only when the view is focused, but that's pretty much it.

Intended behavior on click

I'm not sure about the intended behavior.

I made it so that clicking the button actually adds a new record, and not just focuses the "new record" blue row. I felt it matched more what we would expect, at least in the grid view. Otherwise, clicking the "new record" multiple times would not actually add records but just stay focused on the last line.

But I feel this current behavior is a bit misleading when using the detail view. Maybe in that case we would want to just show the card with blueish inputs?

Button wording

I added the possibility to have different wording on the button depending on the view. For now it renders "New record" on the grid view and "New card" on the detail view.

I did that because it feels different wording for the detail view would maybe better, at least in some other languages than English. In French for example, translating "record" is a bit long and generic.

What do you think?

Related issues

Fixes #366.

Has this been tested?

  • 👍 yes, I added tests to the test suite
  • 💭 no, because this PR is a draft and still needs work
  • 🙅 no, because this is not relevant here
  • 🙋 no, because I need help

Screenshots / Screencasts

Here is a preview:

Note: the preview is not up-to-date, as I updated the code to show we can have different wording for different views. Right now the button renders "new card" when focusing the detail view instead of "new record"

newrecord.mp4

@manuhabitela manuhabitela self-assigned this Feb 7, 2025
@manuhabitela manuhabitela added the preview Launch preview deployment of this PR label Feb 7, 2025
Copy link
Contributor

github-actions bot commented Feb 7, 2025

Deployed commit 9ca236ccfae00c9ea13892784955e4b461b87402 as https://grist-manuhabitela-grist-core-issue-366-new-record-button.fly.dev (until 2025-03-09T14:36:55.866Z)

@manuhabitela manuhabitela force-pushed the issue-366-new-record-button branch from 9ca236c to 337c725 Compare February 7, 2025 14:43
Comment on lines 133 to 138
viewInstance.viewPane,
dom.domComputed(use =>
(use(viewInstance.viewSection.hasFocus) && use(viewInstance.enableAddRow)),
(showNewRecordButton) =>
showNewRecordButton ? newRecordButton(viewInstance) : null
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is out of the viewPane mostly because some views have overflow: hidden on their wrapper and since we want the button to be a bit out of the view it needs to be outside the wrapper.

Copy link
Contributor

github-actions bot commented Feb 7, 2025

Deployed commit 337c72525dd36bab9e683528c9b31335861d0da3 as https://grist-manuhabitela-grist-core-issue-366-new-record-button.fly.dev (until 2025-03-09T14:49:58.524Z)

@manuhabitela manuhabitela force-pushed the issue-366-new-record-button branch from 337c725 to b4953db Compare February 7, 2025 15:05
Copy link
Contributor

github-actions bot commented Feb 7, 2025

Deployed commit b4953db14b5bcc190de62c5ee10879684de573e5 as https://grist-manuhabitela-grist-core-issue-366-new-record-button.fly.dev (until 2025-03-09T15:10:30.522Z)

@vviers
Copy link
Collaborator

vviers commented Feb 7, 2025

My two cents : on a new table that's empty, the new record can be a bit tricky to find (it took me a minute 🙈 )

image

@vviers
Copy link
Collaborator

vviers commented Feb 7, 2025

Also, I'm unclear as to what the different between 1/ the new "Add card" button and 2/ the old "+" on top of the card view is

It seems to me that they do slightly different things (1/ creates a new empty record whereas 2/ doesn't quite yet create the record but gives you the option to do it), but I don't know that they should ? 🤔

image

@manuhabitela
Copy link
Collaborator Author

manuhabitela commented Feb 7, 2025

Also, I'm unclear as to what the different between 1/ the new "Add card" button and 2/ the old "+" on top of the card view is

It seems to me that they do slightly different things (1/ creates a new empty record whereas 2/ doesn't quite yet create the record but gives you the option to do it), but I don't know that they should ? 🤔

Yes the behavior is, for now, purposefully different (see my questioning part).

I feel like for the card view it should stick to always doing the original behavior (number 2). But on the grid view current behavior is better (number 1)?

@lusebille
Copy link
Collaborator

My two cents : on a new table that's empty, the new record can be a bit tricky to find (it took me a minute 🙈 )

image

I think the 'add new record' button is useful if you've got lot of lines (so in lot of cases), we keep the actual behavior too so when you're on a new table, i you're filling a first line , a new one is automatically created, so in that case you don't need to use the'new record button' but it's not a problem because they're two ways to do it

@lusebille
Copy link
Collaborator

Also, I'm unclear as to what the different between 1/ the new "Add card" button and 2/ the old "+" on top of the card view is

It seems to me that they do slightly different things (1/ creates a new empty record whereas 2/ doesn't quite yet create the record but gives you the option to do it), but I don't know that they should ? 🤔

I'm not fully sure about the actual behavior with the actual '+' (for exemple a 'add record' appear and user doesnt know if it's a button or a title, and the '+' is not very visible) , maybe adding 'add new record' button may sound not very useful for the card view but if user use 'add new record' for table view to create 5 new empty lines for example , he will find 5 new empty cards too if he's also using a card view, so better to let him the possibility to create it on the card view with a button

@dsagal
Copy link
Member

dsagal commented Feb 25, 2025

I added a couple of our templates to the preview, to make it easier to play around with slightly more realistic data:

One early thought: when you select a contact in the CRM example, the common next step is to add a new interaction, but there is no indication how to do it -- no "New record" button for interactions. One still needs to know to click into that widget (which means clicking on an existing record, when there are many rows) just to see the option to add a new record.

Another thought is that in a list+card arrangement as in the CRM example, adding a new contact in the table would normally be followed by entering the contact data in the linked card. In a custom app, the natural flow would be a page-wide "Add Contact" button, which focuses the Card widget every time. This is a vague thought, but perhaps someone has ideas.

I think the unifying idea of these observations is that when there are linked widgets, the behavior of "New record" should ideally depend on the shape of linking.

@vviers
Copy link
Collaborator

vviers commented Feb 25, 2025

I think the unifying idea of these observations is that when there are linked widgets, the behavior of "New record" should ideally depend on the shape of linking.

This makes sense to me. Anecdotally, I've seen people use the "Action Button" custom widget for this exact purpose (create a new record in a way that makes sense given the page that you are in, e.g. "add a new contact").

@lusebille
Copy link
Collaborator

I think the unifying idea of these observations is that when there are linked widgets, the behavior of "New record" should ideally depend on the shape of linking.

This makes sense to me. Anecdotally, I've seen people use the "Action Button" custom widget for this exact purpose (create a new record in a way that makes sense given the page that you are in, e.g. "add a new contact").

What this action button look like ? (apart a github folder?)

@emanuelegissi
Copy link

@lusebille
Here is what my New record action button looks like (quite suboptimal).

See this worflow management example I am working on:
https://docs.getgrist.com/iFLERrF5h1rd/Approval-workflow?utm_id=share-doc

Beware: it is still in development!
I still have a problem with record duplication... no easy way with the current plugin api.

@dsagal
Copy link
Member

dsagal commented Mar 6, 2025

@manuhabitela , for the current implementation, I think it addresses only a subset of the confusion people have, and in some cases creates new confusions. So we wouldn't be comfortable releasing it to production as a default behavior.

But doing user-testing and getting real user feedback on this would be great, so we are OK releasing it to production behind a URL parameter (as we discussed elsewhere, something simple like check new URLSearchParams(location.search) directly). This would allow you to test with users on real-life documents and get more feedback.

We can then decide whether to keep this approach, if we need to give the user an option to turn it on or off, or if we want to do something different.

@manuhabitela
Copy link
Collaborator Author

Oh alright!

What I had in mind after we talked about it a few weeks ago, and I think already started coding:

  • we can share a url like https://docs.getgrist.com/?experiment=new-record-button
  • going on this url shows a modal like:

"New record" button

You are about to enable this experimental feature: "New record" button.

To stop using the feature, you can return on this URL at any time: https://docs.getgrist.com/?experiment=new-record-button

[Cancel] / [Enable the feature]

  • clicking Enable the feature would redirect to homepage and have the feature flag enabled in the app[1]
  • going back on the URL would show the same modal but explaining that you are about to disable the feature.

[1] What I was not sure, and don't remember, was if the user-feature stuff was already something completely coded, allowing to easily add new features tied to users, saved in their preferences. If not, I imagined I could just rely on localStorage and make it explicit in the modal that the feature would be enabled only on current machine.

What do you think?

@dsagal
Copy link
Member

dsagal commented Mar 6, 2025

We don't have such infrastructure. What do you think of a simpler approach: if a user opens a page with the special flag, the feature is on, and otherwise it's off? It wouldn't let users work normally with the feature, but it would allow an interview with a user working on their own doc for a session.

Grist docs are single-page apps, so once a page is loaded, the JS state remains. So if you set a global variable like const newRecordButtonFeature = new URLSearchParams(location.search).get('new-record-button'), that value should remain available as you navigate around the pages of the doc.

If you feel it's important to let users opt-in and persist this choice in the browser, I don't object, but it's more stuff to build and maintain, and I am not sure it will get any much use.

@manuhabitela
Copy link
Collaborator Author

I have to say I'm not that convinced with only keeping a variable in the state, since full page loads happen between documents list and document page, it quickly narrows the possibilities to what you just said: a specific testing session on one given document.

I feel the dialog + keeping state in localstorage is not that much more code to maintain, stays rather simple (only client-side), and a good compromise between "only keep in js state for current doc" vs "keep it in user prefs server-side".

It easily allows to globally share a link saying "hey, you can enable this experimental feature with this url and then work as usual on your docs to get a feel for it".

So if you don't object I'd rather implement that. I actually checked earlier and I was almost done implementing the dialog + localstorage save, it's not that much code and it's pretty simple 😇

@dsagal
Copy link
Member

dsagal commented Mar 6, 2025

Sounds good!

- add logic to enable the toggling of "experiments" via URL search
params
- first experiment of this sort is a "new record button" that is visible
at the bottom left of a grid or detail view.
@manuhabitela manuhabitela force-pushed the issue-366-new-record-button branch from b4953db to ad9744b Compare March 20, 2025 18:45
@manuhabitela manuhabitela marked this pull request as ready for review March 20, 2025 18:45
@manuhabitela
Copy link
Collaborator Author

@dsagal what do you think of this implementation? Note: tests tell me I missed a little something but I have to go right now 🤡

Here is a preview of what it does (@lusebille):

grist-new-record-button.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gouv.fr preview Launch preview deployment of this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Add new record" button
5 participants