Skip to content

Commit

Permalink
[fields] Fix readOnly behavior (mui#12609)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasTy authored and DungTiger committed Jul 23, 2024
1 parent 4016203 commit e743f4f
Showing 1 changed file with 3 additions and 1 deletion.
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);
return;
}
const browserStartIndex = inputRef.current!.selectionStart ?? 0;
Expand Down

0 comments on commit e743f4f

Please sign in to comment.