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

withEditable HOC #28

Open
hoodsy opened this issue Jul 9, 2018 · 6 comments
Open

withEditable HOC #28

hoodsy opened this issue Jul 9, 2018 · 6 comments
Assignees

Comments

@hoodsy
Copy link
Contributor

hoodsy commented Jul 9, 2018

@maticzav Not sure how exactly to wire this up to work with mutations – I imagine the HOC receives handleSave or something like that, so that each field can be updated in place.

<EditableClassTitle
value={data.class.name}
handleSave={() => {}}
/>

Demo: https://homeroom-live.slack.com/files/U8SBTK67M/FBNKDHE3H/witheditable.mov

@maticzav
Copy link
Contributor

I think there are two options, but I can tell you upfront that I lean towards the second one. 😂

So, the saving process means taking all the current values and running Apollo mutation which updates the saved values of the fields. I imagine we can achieve this most easily if we use getInitialProps function and query everything once customer lands on our page, and copy everything to the internal state.

Once the customer changes values, we only update the component state and, in the end, run a mutation which updates values on the server as well.

My thoughts on how we should trigger the update;

  1. Use debounce function and save automatically after some time.
  2. Display a save button and save everything once it's pressed or the customer submits the form.

@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 10, 2018

If the user is editing text inline, the expectation is that their changes will be saved after each edit... If we go save button, I think a typical form makes more sense.

That being said, what if we had the same save trigger wired up to each EditableComponent? Each time one of them is changed and the user hits enter, clicks the confirm checkmark, or clicks off the input, then the save is registered

@maticzav
Copy link
Contributor

Whoa yea that could be cool! Have you seen onBlur property yet? I think we could do a ful mutation every time something changes and make it visible that it changed - maybe we should disable everything when it’s updating and show indicator?

I think we can wire everytihng up in a Mutation component and just include the trigger inside every component

@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 11, 2018 via email

@maticzav
Copy link
Contributor

I would say it depends; if we want to make it feel responsive then no. I think it might be good to keep states in sync this way. But now that I think of it might be unnecessary. 👌

@hoodsy
Copy link
Contributor Author

hoodsy commented Jul 13, 2018

Needs to be wired up but won't be used in this release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants