Merge branch 'main' into adilallo/fix/CR-394-rule-admin-ops-token-umami
This commit is contained in:
commit
fb5122c91f
6 files changed
+111
-22
No files matched your search
@@ -21,6 +21,14 @@ import { useTranslation } from "../../../contexts/MessagesContext";
|
||||
import { SelectInputView } from "./SelectInput.view";
|
||||
import type { SelectInputProps, SelectOptionData } from "./SelectInput.types";
|
||||
|
||||
function isFocusVisible(el: Element): boolean {
|
||||
try {
|
||||
return el.matches(":focus-visible");
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Figma: "Control / SelectInput". Custom-styled select dropdown
|
||||
* with a labelled trigger button and floating option menu.
|
||||
@@ -277,11 +285,15 @@ const SelectInputContainer = forwardRef<HTMLButtonElement, SelectInputProps>(
|
||||
],
|
||||
);
|
||||
|
||||
// Handle focus to detect mouse vs keyboard
|
||||
const handleFocus = useCallback(() => {
|
||||
if (disabled) return;
|
||||
|
||||
const method = wasMouseDownRef.current ? "mouse" : "keyboard";
|
||||
const el = selectRef.current;
|
||||
const method = wasMouseDownRef.current
|
||||
? "mouse"
|
||||
: el && isFocusVisible(el)
|
||||
? "keyboard"
|
||||
: null;
|
||||
|
||||
if (shouldAutoManageFocus) {
|
||||
setIsFocused(true);
|
||||
@@ -308,15 +320,13 @@ const SelectInputContainer = forwardRef<HTMLButtonElement, SelectInputProps>(
|
||||
[closeMenu, shouldAutoManageFocus],
|
||||
);
|
||||
|
||||
// Determine actual state:
|
||||
// - Active: when clicked (mouse focus) or when dropdown is open
|
||||
// - Focus: when tabbed (keyboard focus)
|
||||
// - Default: when not focused
|
||||
const actualState = shouldAutoManageFocus
|
||||
? isOpen || isFocused
|
||||
? focusMethod === "mouse" || isOpen
|
||||
? "active"
|
||||
: "focus"
|
||||
: focusMethod === "keyboard"
|
||||
? "focus"
|
||||
: "default"
|
||||
: "default"
|
||||
: externalState;
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ const TextAreaContainer = forwardRef<HTMLTextAreaElement, TextAreaProps>(
|
||||
: `${currentSize.label} `;
|
||||
|
||||
const textareaClasses = `
|
||||
scrollbar-design w-full transition-all duration-200 ease-in-out resize-none
|
||||
appearance-none scrollbar-design w-full transition-all duration-200 ease-in-out resize-none
|
||||
${appearance === "embedded" || appearance === "compose" ? "rounded-[var(--radius-300)]" : "border"}
|
||||
${appearance === "compose" ? "text-medium-paragraph" : currentSize.textarea}
|
||||
${stateStyles.textarea}
|
||||
|
||||
@@ -6,6 +6,14 @@ import { useTranslation } from "../../../contexts/MessagesContext";
|
||||
import { TextInputView } from "./TextInput.view";
|
||||
import type { TextInputProps } from "./TextInput.types";
|
||||
|
||||
function isFocusVisible(el: Element): boolean {
|
||||
try {
|
||||
return el.matches(":focus-visible");
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Figma: "Control / TextInput". Single-line text input with size
|
||||
* variants and managed default/active/focus/error states.
|
||||
@@ -60,15 +68,13 @@ const TextInputContainer = forwardRef<HTMLInputElement, TextInputProps>(
|
||||
const shouldAutoManageFocus =
|
||||
externalState === "default" || externalState === undefined;
|
||||
|
||||
// Determine actual state:
|
||||
// - Active: when clicked (mouse focus)
|
||||
// - Focus: when tabbed (keyboard focus)
|
||||
// - Default: when not focused
|
||||
const actualState = shouldAutoManageFocus
|
||||
? isFocused
|
||||
? focusMethod === "mouse"
|
||||
? "active"
|
||||
: "focus"
|
||||
: focusMethod === "keyboard"
|
||||
? "focus"
|
||||
: "default"
|
||||
: "default"
|
||||
: externalState;
|
||||
|
||||
@@ -180,8 +186,9 @@ const TextInputContainer = forwardRef<HTMLInputElement, TextInputProps>(
|
||||
|
||||
// Base classes without border (border is added in state styles)
|
||||
const inputClasses = `
|
||||
w-full transition-all duration-200 ease-in-out
|
||||
focus:outline-none focus:ring-0
|
||||
appearance-none w-full transition-all duration-200 ease-in-out
|
||||
focus:outline-none focus:ring-0 focus:shadow-none
|
||||
caret-[var(--color-content-default-primary)]
|
||||
placeholder:text-[var(--color-content-default-tertiary)]
|
||||
${sizeStyles.input}
|
||||
${stateStyles.input}
|
||||
@@ -216,19 +223,18 @@ const TextInputContainer = forwardRef<HTMLInputElement, TextInputProps>(
|
||||
}
|
||||
};
|
||||
|
||||
// Custom focus handler to detect mouse vs keyboard
|
||||
const handleFocus = (e: React.FocusEvent<HTMLInputElement>) => {
|
||||
if (disabled) return;
|
||||
|
||||
// Detect if focus came from keyboard (Tab) or mouse (click)
|
||||
// If mouseDown was detected before focus, it's a mouse click (active)
|
||||
// Otherwise, it's keyboard navigation (focus)
|
||||
const method = wasMouseDownRef.current ? "mouse" : "keyboard";
|
||||
const method = wasMouseDownRef.current
|
||||
? "mouse"
|
||||
: isFocusVisible(e.currentTarget)
|
||||
? "keyboard"
|
||||
: null;
|
||||
|
||||
if (shouldAutoManageFocus) {
|
||||
setIsFocused(true);
|
||||
setFocusMethod(method);
|
||||
// Reset mouse down flag after focus is processed
|
||||
wasMouseDownRef.current = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,39 @@
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Dark text fields: drop OS chrome (Safari/Chrome inner bevel on focus)
|
||||
* and the yellow autofill wash. Utilities on each control still win.
|
||||
*/
|
||||
@layer base {
|
||||
input[type="text"],
|
||||
input[type="email"],
|
||||
input[type="password"],
|
||||
input[type="search"],
|
||||
input[type="url"],
|
||||
input[type="tel"],
|
||||
input[type="number"],
|
||||
input:not([type]),
|
||||
textarea {
|
||||
appearance: none;
|
||||
color-scheme: dark;
|
||||
caret-color: var(--color-content-default-primary);
|
||||
}
|
||||
|
||||
input:-webkit-autofill,
|
||||
input:-webkit-autofill:hover,
|
||||
input:-webkit-autofill:focus,
|
||||
input:-webkit-autofill:active,
|
||||
textarea:-webkit-autofill,
|
||||
textarea:-webkit-autofill:hover,
|
||||
textarea:-webkit-autofill:focus {
|
||||
-webkit-text-fill-color: var(--color-content-default-primary);
|
||||
caret-color: var(--color-content-default-primary);
|
||||
box-shadow: inset 0 0 0 100vmax var(--color-surface-default-secondary);
|
||||
transition: background-color 99999s ease-out;
|
||||
}
|
||||
}
|
||||
|
||||
@theme inline {
|
||||
/* Custom breakpoints */
|
||||
--breakpoint-xsm: 429px;
|
||||
|
||||
Reference in new issue
Block a user