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

Reuse existing boxes when editing #190

Open
MikkelPaulson opened this issue Oct 29, 2021 · 4 comments
Open

Reuse existing boxes when editing #190

MikkelPaulson opened this issue Oct 29, 2021 · 4 comments
Labels
enhancement Minor feature or improvement to an existing feature frontend Work primarily involving JS/CSS help wanted Tasks that I can't/don't plan to do myself

Comments

@MikkelPaulson
Copy link
Collaborator

MikkelPaulson commented Oct 29, 2021

  • When editing the Thing that was most recently displayed, update the existing block rather than creating a new one.
  • Highlight the changed line(s).
@MikkelPaulson MikkelPaulson added this to the 0.3 milestone Oct 29, 2021
@MikkelPaulson MikkelPaulson modified the milestones: 0.3 - polish, 0.2 - MVP2 Nov 1, 2021
@MikkelPaulson MikkelPaulson added enhancement Minor feature or improvement to an existing feature rust help wanted Tasks that I can't/don't plan to do myself and removed javascript labels Dec 1, 2022
@MikkelPaulson MikkelPaulson removed this from the 0.3 - polish milestone Dec 2, 2022
@MikkelPaulson MikkelPaulson added the frontend Work primarily involving JS/CSS label Dec 6, 2022
@ChrisRenfrow
Copy link
Contributor

ChrisRenfrow commented Aug 16, 2024

@MikkelPaulson

I am interested in implementing this, and after taking a look around I came up with a couple of high-level approaches to solve the problem of "how can we know if the thing we're about to output carries the same identity as any thing in view?"

Approach no.1 could involve modifying /core/src/world/*/view.rs to populate the id attribute of each .thing-box with a unique value derived from the thing's UUID. Then, in the front-end we can try and select the matching element in the document and, if it exists and is "in view", replace the existing element.

A less invasive option might be to assign a unique id derived from the name of the thing (h1 contents) in the front-end, amending the output (if it's of class .thing-box) with the derived id before inserting into the document and performing the final step from the other approach.

Edit: Some potential downsides with this approach is that edits to the thing's name will spawn a new box rather than replace the existing one. Depending on your perspective, this might be an intended result?

Which of these sound more appealing to you? Is there another path to consider?

@MikkelPaulson
Copy link
Collaborator Author

MikkelPaulson commented Aug 17, 2024

@ChrisRenfrow Sounds good, go for it!

I had something like the first approach in mind. There's no need to hack it on as a frontend-only change. However, be mindful that the id property is supposed to be unique to a DOM; using uuid (or something else) instead would be better.

I would only update the most recent box, rather than anything still visible on the screen. And I suggest a CSS animation to show that a field has been changed, maybe highlighting it for a second or something. That diff can be done client (JS)-side; trying to get that information across the WASM FFI would be a pain.

@ChrisRenfrow
Copy link
Contributor

ChrisRenfrow commented Aug 17, 2024

Oh, I think I understand, you're asking that I use some arbitrary property like data-uuid instead of id? That works (and makes sense) for me. And you answered my next line of questioning, so I think I'm set to begin. :)

@MikkelPaulson
Copy link
Collaborator Author

Exactly. Because the same entity can appear multiple times on a page, we just don't want it to appear consecutively anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Minor feature or improvement to an existing feature frontend Work primarily involving JS/CSS help wanted Tasks that I can't/don't plan to do myself
Projects
None yet
Development

No branches or pull requests

2 participants