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

[fields] Fix readOnly behavior #12609

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ export const useFieldV6TextField: UseFieldTextField<false> = (params) => {
getActiveSectionIndexFromDOM: () => {
const browserStartIndex = inputRef.current!.selectionStart ?? 0;
const browserEndIndex = inputRef.current!.selectionEnd ?? 0;
if (browserStartIndex === 0 && browserEndIndex === 0) {
const isInputReadOnly = !!inputRef.current?.readOnly;
if ((browserStartIndex === 0 && browserEndIndex === 0) || isInputReadOnly) {
return null;
}

Expand All @@ -196,6 +197,7 @@ export const useFieldV6TextField: UseFieldTextField<false> = (params) => {

const syncSelectionFromDOM = () => {
if (readOnly) {
setSelectedSections(null);
Copy link
Member Author

Choose a reason for hiding this comment

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

return;
}
const browserStartIndex = inputRef.current!.selectionStart ?? 0;
Expand Down