Skip to content

fix: allow input focus when readonly#5014

Merged
chasestarr merged 3 commits intouber:masterfrom
selfdocumentingcode:master
Aug 29, 2022
Merged

fix: allow input focus when readonly#5014
chasestarr merged 3 commits intouber:masterfrom
selfdocumentingcode:master

Conversation

@selfdocumentingcode
Copy link

Fixes #4992

Description

Input and Textarea fields cannot be focused if the readOnly prop is true.
This prevents the read-only fields from visually showing that they are focused and also makes them no longer emit focus and blur events.

This behavior is correct for fields with disabled attribute, but not for fields with readonly attribute.

The difference between disabled and readonly is that read-only controls can still function and are still focusable, whereas disabled controls can not receive focus and are not submitted with the form and generally do not function as controls until they are enabled.

https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/readonly#attribute_interactions

Sandbox: https://codesandbox.io/s/base-web-input-forked-7f9vwc?file=/src/example.js

Scope

Patch: Bug Fix

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jul 5, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit e9e4adb:

Sandbox Source
Basic usage Configuration
Base Web - Input (forked) PR
Base Web - Input (forked) Issue #4992

Copy link
Collaborator

@chasestarr chasestarr left a comment

Choose a reason for hiding this comment

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

Sorry to let this sit for a while. This change looks good to me, but we've converted over to typescript. Do you mind updating to that?

@selfdocumentingcode
Copy link
Author

No worries. I will, but it'll have to be next week.

@selfdocumentingcode
Copy link
Author

@chasestarr Hi. I updated the .tsx files.

@chasestarr
Copy link
Collaborator

Thank you

@chasestarr chasestarr merged commit 85992c3 into uber:master Aug 29, 2022
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.

Input and Textarea with readOnly prop cannot be focused

2 participants