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

issue-1134 Insert newlines in TextAreaCell only via keyboard shortcut #1211

Merged
merged 5 commits into from
Jul 22, 2022

Conversation

nk183
Copy link
Contributor

@nk183 nk183 commented Mar 22, 2022

Fixes #1134

Technical details

What this pr does
Pressing Enter with any combination of the following modifier keys inserts a newline at the users cursor position:

Ctrl
Alt
Meta (aka "Cmd" on Mac OS)

ToDo

Currently after inserting new line using keyboard,the textarea field focus losses

Screenshots

simplescreenrecorder-2022-03-22_15.35.14.mp4

Checklist

  • My pull request has a descriptive title (not a vague title like Update index.md).
  • My pull request targets the master branch of the repository
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no
    visible errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

@nk183 nk183 requested review from a team and seancolsen March 22, 2022 10:16
@nk183
Copy link
Contributor Author

nk183 commented Mar 22, 2022

Hi @pavish can you please help me with this
The textarea losses it focus after insertion of newline using shortcut keys
I have applied focus on textarea Reference after dealing with key shortcuts.

@pavish
Copy link
Member

pavish commented Mar 22, 2022

@nk183 The changes required here are mostly on the TextAreaCell component and the SteppedInputCell components.

Enter + (ctrl/shift/cmd) controls would be dispatching Enter keydown events, which in this case also switches the mode from edit to select. This is the cause for the loss of focus.

I'm marking this PR as draft since it is still being worked upon.

@pavish pavish marked this pull request as draft March 22, 2022 11:36
@nk183
Copy link
Contributor Author

nk183 commented Mar 24, 2022

hi @pavish it is working as required, but I think code can be made more clean can you please guide me.
I am working on making a enterBehavior as a property and can you tell how can I write this, this seems redundant.(how can I handle shitkey in switch case("Enter"))

@kgodey kgodey added the pr-status: review A PR awaiting review label Mar 24, 2022
@pavish pavish marked this pull request as ready for review March 24, 2022 21:27
Copy link
Member

@pavish pavish left a comment

Choose a reason for hiding this comment

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

We had a discussion over one of our office hours over this PR, where we discussed an alternate approach. I've added it here to keep track.

@nk183

  1. Create an optional boolean prop in TextArea component which decides whether or not to handle meta+enter, ctrl+enter and alt+enter. Eg., export let addNewLineOnAllEnterKeyCombinations = false.
  2. Move the keydown event handler within TextArea and handle adding new line based on the above prop.
  3. In TextAreaCell, only pass the prop's value as true.
  4. Fix all linting errors.

@pavish pavish assigned nk183 and unassigned pavish Apr 5, 2022
@pavish pavish added pr-status: revision A PR awaiting follow-up work from its author after review and removed pr-status: review A PR awaiting review labels Apr 5, 2022
@nk183 nk183 closed this Apr 5, 2022
@nk183 nk183 reopened this Apr 5, 2022
@codecov-commenter

This comment was marked as off-topic.

@nk183
Copy link
Contributor Author

nk183 commented Apr 6, 2022

hi @pavish I have added the required changed.

@pavish pavish assigned pavish and unassigned nk183 Apr 6, 2022
@pavish pavish added pr-status: review A PR awaiting review and removed pr-status: revision A PR awaiting follow-up work from its author after review labels Apr 6, 2022
@pavish
Copy link
Member

pavish commented Apr 12, 2022

@nk183 Thank you for your work on this PR! The changes look good to me.

I've been holding off on merging this PR since there are considerable changes in related components in parallel PRs. I'll add commits to this PR to handle the changes and merge it in the upcoming week.

@pavish pavish added pr-status: revision A PR awaiting follow-up work from its author after review and removed pr-status: review A PR awaiting review labels Apr 12, 2022
@pavish pavish added needs: unblocking Blocked by other work and removed pr-status: revision A PR awaiting follow-up work from its author after review labels Apr 12, 2022
@github-actions
Copy link

github-actions bot commented Jul 9, 2022

This pull request has not been updated in 45 days and is being marked as stale. It will automatically be closed in 30 days if not updated by then.

@github-actions github-actions bot added the stale label Jul 9, 2022
@pavish pavish added pr-status: review A PR awaiting review and removed needs: unblocking Blocked by other work stale labels Jul 21, 2022
@pavish pavish enabled auto-merge July 21, 2022 23:33
@pavish pavish merged commit 196411c into mathesar-foundation:master Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-status: review A PR awaiting review
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Insert newlines in TextAreaCell only via keyboard shortcut
4 participants