Skip to content

Commit c8cdab5

Browse files
committed
Disable status pill interactions when component is disabled
1 parent 443497b commit c8cdab5

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

apps/web/app/(org)/dashboard/caps/components/web-recorder-dialog/MicrophoneSelector.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ export const MicrophoneSelector = ({
4545
const shouldRequestPermission =
4646
permissionSupported && permissionState !== "granted";
4747

48-
const statusPillDisabled = !shouldRequestPermission && !micEnabled;
48+
const statusPillDisabled =
49+
disabled || (!shouldRequestPermission && !micEnabled);
4950

5051
const statusPillClassName = clsx(
5152
"px-[0.375rem] h-[1.25rem] min-w-[2.5rem] rounded-full text-[0.75rem] leading-[1.25rem] flex items-center justify-center font-normal transition-colors duration-200 disabled:opacity-100 disabled:pointer-events-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1 focus-visible:ring-[var(--blue-8)]",
@@ -60,6 +61,12 @@ export const MicrophoneSelector = ({
6061
const handleStatusPillClick = async (
6162
event: MouseEvent<HTMLButtonElement> | KeyboardEvent<HTMLButtonElement>,
6263
) => {
64+
if (disabled) {
65+
event.preventDefault();
66+
event.stopPropagation();
67+
return;
68+
}
69+
6370
if (shouldRequestPermission) {
6471
event.preventDefault();
6572
event.stopPropagation();
@@ -90,6 +97,14 @@ export const MicrophoneSelector = ({
9097
};
9198

9299
const handleStatusPillKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {
100+
if (disabled) {
101+
if (event.key === "Enter" || event.key === " ") {
102+
event.preventDefault();
103+
event.stopPropagation();
104+
}
105+
return;
106+
}
107+
93108
if (event.key === "Enter" || event.key === " ") {
94109
handleStatusPillClick(event);
95110
}

0 commit comments

Comments
 (0)