Skip to content

Auto-select entire input field on focus#811

Merged
wassgha merged 4 commits intomasterfrom
bug/746-auto-select-on-focus
Mar 29, 2020
Merged

Auto-select entire input field on focus#811
wassgha merged 4 commits intomasterfrom
bug/746-auto-select-on-focus

Conversation

@barklund
Copy link
Copy Markdown
Contributor

Fixes #736.

This ensures selection of entire text field on focus. This makes it work for symbol-postfixed inputs when tabbing to them.

But more than that, it actually also selects the entire text field when mouse clicking into a text field. I think this is actually good behaviour.

If desired, we can loosen this effect to only occur on keyboard focus changes and not mouse focus changes.

Demo – first focusing by mouse, then by pressing (shift +) tab:
focusselect

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2020

Size Change: +5.06 kB (1%)

Total Size: 499 kB

Filename Size Change
assets/js/edit-story.js 429 kB +4.06 kB (0%)
assets/js/stories-dashboard.js 66.4 kB +999 B (1%)
ℹ️ View Unchanged
Filename Size Change
assets/css/edit-story.css 3.01 kB 0 B
assets/css/stories-dashboard.css 206 B 0 B

compressed-size-action

@miina
Copy link
Copy Markdown
Contributor

miina commented Mar 27, 2020

@barklund From testing:

It currently doesn't seem to work for opacity fields which go together with <Color>:
opacity

@swissspidy swissspidy added the Type: Enhancement New feature or improvement of an existing feature label Mar 27, 2020
@barklund
Copy link
Copy Markdown
Contributor Author

It currently doesn't seem to work for opacity fields which go together with <Color>:

Ah yes, that's a different component that Numeric. Will re-implement here.

@barklund barklund requested a review from dvoytenko March 28, 2020 03:15
@barklund
Copy link
Copy Markdown
Contributor Author

It currently doesn't seem to work for opacity fields which go together with <Color>:

Ah yes, that's a different component that Numeric. Will re-implement here.

Done. @miina, PTAL.

Copy link
Copy Markdown
Contributor

@wassgha wassgha left a comment

Choose a reason for hiding this comment

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

nits

Comment on lines +25 to +26
const handleFocusIn = useCallback(() => setIsFocused(true), []);
const handleFocusOut = useCallback(() => setIsFocused(false), []);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we rename these to handleFocus and handleBlur ? That's more standard

@googlebot
Copy link
Copy Markdown

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@wassgha
Copy link
Copy Markdown
Contributor

wassgha commented Mar 29, 2020

@googlebot I consent

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@wassgha wassgha merged commit 02dd741 into master Mar 29, 2020
@wassgha wassgha deleted the bug/746-auto-select-on-focus branch March 29, 2020 04:48
obetomuniz added a commit that referenced this pull request Mar 30, 2020
* master:
  Update list of Google Fonts
  Bump babel-jest from 25.2.3 to 25.2.4 (#851)
  Resize video while resizing (#804)
  Bump @wordpress/components from 9.2.5 to 9.2.6 (#839)
  Bump eslint-plugin-testing-library from 2.2.3 to 3.0.0 (#849)
  Bump react-moveable from 0.18.1 to 0.19.0 (#850)
  Bump lint-staged from 10.0.9 to 10.0.10
  Bump eslint-plugin-import from 2.20.1 to 2.20.2 (#846)
  Auto-select entire input field on focus (#811)
  Disallow masking for background. (#827)
  Reduce timing difference for entering edit mode. (#829)
  Clicking on media in the gallery should never insert as background (#841)
  Bump @testing-library/dom from 7.1.2 to 7.1.3 (#843)
  Reorderable drag and drop component (#709)
  Minimize layer panel height + fixes for expanding/collapsing (#704)
  remove lingering extra styled component import comment
  adding tests for which icon is present on chip bookmark
  some clean up
  bookmark chip ui component. 2 sizes controlled by constants.js. Storybook + a very basic test
  Template Animations: Added float-on animation (#618)
@swissspidy
Copy link
Copy Markdown
Collaborator

Added to alpha branch

swissspidy pushed a commit that referenced this pull request Mar 30, 2020
* Auto-select entire input field on focus

* Rewrite to generic hook

* Reuse focus-select hook for opacity input

* Rename onFocusOut -> onBlur

Co-authored-by: Wassim Gharbi <wassgha@gmail.com>
obetomuniz added a commit that referenced this pull request Mar 30, 2020
* master: (60 commits)
  return stories from async func
  Fix case naming. Story state location.
  Bump @testing-library/dom from 7.1.3 to 7.1.4 (#866)
  Renamed status var inside loop
  Use wordpress i18n for status labels
  Added API-endpoint for story data
  Bump lint-staged from 10.0.10 to 10.1.0 (#863)
  Revert "Aspect Ratio changed after dragging video to upload as background"
  add test for updateElementsByVideoId
  Fix typo to fix blob issue.
  Update list of Google Fonts
  Exit edit mode on link change
  Bump babel-jest from 25.2.3 to 25.2.4 (#851)
  Resize video while resizing (#804)
  Bump @wordpress/components from 9.2.5 to 9.2.6 (#839)
  Bump eslint-plugin-testing-library from 2.2.3 to 3.0.0 (#849)
  Bump react-moveable from 0.18.1 to 0.19.0 (#850)
  Bump lint-staged from 10.0.9 to 10.0.10
  Bump eslint-plugin-import from 2.20.1 to 2.20.2 (#846)
  Auto-select entire input field on focus (#811)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Enhancement New feature or improvement of an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Side panel: select all on input focus

6 participants