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

textInput pass 3 - adding some styling for background, fix cursor \n issue, and some more cleanup #578

Merged
merged 29 commits into from
Apr 13, 2024

Conversation

hanbollar
Copy link
Contributor

@hanbollar hanbollar commented Apr 10, 2024

Linking

related to #513

pass1 was #524, pass2 was #546


all the rest of this section of the pr description is the same as in the #524 / #546 prs

  • fix selection index is always zero
  • consolidate input handling if possible (up/down cursor special case)
  • handle new line wonkiness
  • background color niceness for visual

Required to Merge

  • PASS - all necessary actions must pass (excluding the auto-skipped ones)
  • TEST IN HEADSET - main dev-testing-example and any of the other examples still work as expected
  • VIDEO - if this pr changes something visually - post a video here of it in headset-MR and/or on desktop (depending on what it affects) for the reviewer to reference.
  • TITLE - make sure the pr's title is updated appropriately as it will be used to name the commit on merge
  • BREAKING CHANGE
    • DOCUMENTATION: This includes any changes to html tags and their components
      • make a pr in the documentation repo that updates the manual docs to match the breaking change
      • link the pr of the documentation repo here: #pr
      • that pr must be approved by @lobau
    • SAMPLES/INDEX.HTML: This includes any changes (html tags or otherwise) that must be done to our landing page submodule as an effect of this pr's updates
      • make a pr in the mrjs landing page repo that updates the landing page to match the breaking change
      • link the pr of the landing page repo here: #pr
      • that pr must be approved by @hanbollar

Signed-off-by: hanbollar <[email protected]>
Copy link

render bot commented Apr 10, 2024

@hanbollar hanbollar marked this pull request as draft April 10, 2024 17:54
@hanbollar
Copy link
Contributor Author

pausing on this for a short bit

@hanbollar
Copy link
Contributor Author

hanbollar commented Apr 11, 2024

todos:

@hanbollar hanbollar changed the title WIP - input pass 3 textInput pass 3 - adding some styling for background, fix cursor \n issue, and some more cleanup Apr 12, 2024
@hanbollar
Copy link
Contributor Author

if all is good - then this is enough to re-expose this as a tag and in documentation repo with future issues created off of this for more work

Signed-off-by: hanbollar <[email protected]>
Signed-off-by: hanbollar <[email protected]>
@hanbollar
Copy link
Contributor Author

hanbollar commented Apr 12, 2024

if all is good - then this is enough to re-expose this as a tag and in documentation repo with future issues created off of this for more work

future niceties include:

i'll make individual issues off of these once this pr is merged for easier tracking

Signed-off-by: hanbollar <[email protected]>
@hanbollar hanbollar marked this pull request as ready for review April 12, 2024 22:14
@michaelthatsit
Copy link
Member

Screen.Recording.2024-04-12.at.4.48.06.PM.mov

@michaelthatsit
Copy link
Member

Still looking at the code but the cursor seems a little higher than it should be. Also did you test with other font sizes?

@hanbollar
Copy link
Contributor Author

hanbollar commented Apr 12, 2024

Still looking at the code but the cursor seems a little higher than it should be. Also did you test with other font sizes?

the cursor looks higher because im sort of faking the background height (the coloring one) to fit it decently with like a slight offset for niceties, but that nicety can probably be improved compared to the quick way im doing it (it's the background scale offset in textsystem)- the cursor currently matches the specific text location, with an x offset of cursor width so there isnt touching at least

redo: i had misinterpretated your cursor statement --> actual response:

  • Yea the cursor issue is a little off because i had issue with line height directly (ie grabbing the difference about the actual troika selection object top and top of the troika represented line itself) - if you have an idea for how to do that im all ears, the conversion was a bit wonky

and yea had tested with other font sizes - it doesnt scale exactly as i want atm, but it does at least start at the right top and width position - was leaving that as a future noodle to not be a blocker on this one

document.body.appendChild(inputElement); // Ensure it's part of the DOM for event capturing

// Ensure it's part of the DOM for event capturing
document.body.appendChild(inputElement);
Copy link
Member

Choose a reason for hiding this comment

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

I think we talked about this but why aren't we putting this in the shadow root? might scale a little better. especially for embedded experiences.

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 no main reason - i can swap it to that

Copy link
Member

Choose a reason for hiding this comment

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

Yeah it shouldn't be a huge issue and then you wouldn't need to do the 9999999/-99999999 absolute positions. you can just set it to display:none in CSS.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that is so much cleaner haha

Copy link
Member

Choose a reason for hiding this comment

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

Yeah use this as an example #578 (comment)

It's one of those stack overflow tricks I picked up the first time I was trying with MRTextField.

this.lineHeight = 1.2; // Default line height, can be adjusted as needed
this.object3D.name = 'textField';

// this.wrapper = this.shadowRoot.appendChild(document.createElement('div'));
Copy link
Member

Choose a reason for hiding this comment

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

Related to my other comment. why a hidden field in the DOM instead of an actual field in the shadow?

@@ -73,7 +107,7 @@ export class MRTextFieldEntity extends MRTextInputEntity {

// Ensure the cursor position is updated to reflect the current caret position
setTimeout(() => {
Copy link
Member

Choose a reason for hiding this comment

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

what's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if we end up needing to pass the event info/etc to the function within that, we want the timeout to have a delay s.t. the event actually holds all the proper information (since it's a press/trigger type one) otherwise, the events can get delayed so the next time you grab the info, you're grabbing the previous version until the next event gets called (it's like the stack gets delayed by one or more steps if that makes sense)


tldr atm this setup is no longer needed since i dont pass the 'event' object to the cursor function anymore, but if we ever do it again, it will be needed with something > 0

^ given this, lmk if you'd want it removed or kept just in case

Copy link
Member

Choose a reason for hiding this comment

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

I'd say if we're not using it we can lose it for the sake of cleanliness

@michaelthatsit
Copy link
Member

Overall it's pretty solid. I don't think you're blocking anything ATM so try and make the Shadow DOM changes we discussed.

Some notes for what I think we need by v1:

  • select cursor position (blocked by click events I think)
  • Text selection
  • copy/paste
  • bonus: spell check

@michaelthatsit
Copy link
Member

Screenshot 2024-04-12 at 5 31 19 PM

Accidental caps but just noticed that text doesn't stay in the textarea if you type too far.

@hanbollar
Copy link
Contributor Author

hanbollar commented Apr 13, 2024

Screenshot 2024-04-12 at 5 31 19 PM Accidental caps but just noticed that text doesn't stay in the textarea if you type too far.

yupyup - one of the few task for after this was to add in a scrolling offset - so that the number of lines are only limited to what can show up in the main area but the text can be handled properly (ie textobj only shows what's visible but the hiddenInput can handle the whole amount), so i didnt make a change to limit the height of it based on text (we also cant do mask of a mask either, so that wouldnt hv been worth it)

if that's a blocker for this pr lmk, but i had added in the todos within the code as a task after this pr

@michaelthatsit
Copy link
Member

No blocker but let's prioritize it on the next pass. Good work!

@hanbollar hanbollar merged commit f4e896d into main Apr 13, 2024
6 checks passed
@hanbollar hanbollar deleted the hb-input-pass3 branch April 13, 2024 00:42
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

Successfully merging this pull request may close these issues.

2 participants