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

fix: ComboBox readonly state fixed #17457

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/react/src/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@
if (onToggleClick) {
onToggleClick(event);
}
if (readOnly) {
// Prevent the list from opening if readOnly is true
event.preventDownshiftDefault = true;
event?.persist?.();
return;

Check warning on line 593 in packages/react/src/components/ComboBox/ComboBox.tsx

View check run for this annotation

Codecov / codecov/patch

packages/react/src/components/ComboBox/ComboBox.tsx#L591-L593

Added lines #L591 - L593 were not covered by tests
}

if (event.target === textInput.current && isOpen) {
event.preventDownshiftDefault = true;
Expand Down Expand Up @@ -749,6 +755,12 @@
evt.preventDefault();
}
},
onClick: (evt: MouseEvent<HTMLInputElement>) => {
// Prevent the default behavior which would open the list
evt.preventDefault();
// Focus on the element as per readonly input behavior
evt.currentTarget.focus();
},
}
: {};

Expand Down
Loading