mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-27 03:10:11 +08:00
🐛 fix(frontend): 修复 macOS Caps Lock 输入浮层
This commit is contained in:
@@ -3,15 +3,14 @@ import { describe, expect, it } from 'vitest';
|
||||
import { applyNoAutoCapAttributes, applyNoAutoCapAttributesWithin, noAutoCapInputProps } from './inputAutoCap';
|
||||
|
||||
describe('inputAutoCap', () => {
|
||||
it('exports input props that disable auto capitalization and correction', () => {
|
||||
it('exports input props that disable correction without forcing native capitalization state', () => {
|
||||
expect(noAutoCapInputProps).toEqual({
|
||||
autoCapitalize: 'none',
|
||||
autoCorrect: 'off',
|
||||
spellCheck: false,
|
||||
});
|
||||
});
|
||||
|
||||
it('applies lowercase DOM attributes to inputs and textareas', () => {
|
||||
it('applies correction attributes to inputs and textareas without autocapitalize', () => {
|
||||
const inputAttributes: Record<string, string> = {};
|
||||
const textareaAttributes: Record<string, string> = {};
|
||||
const input = {
|
||||
@@ -30,10 +29,10 @@ describe('inputAutoCap', () => {
|
||||
applyNoAutoCapAttributes(input);
|
||||
applyNoAutoCapAttributes(textarea);
|
||||
|
||||
expect(inputAttributes.autocapitalize).toBe('none');
|
||||
expect(inputAttributes.autocapitalize).toBeUndefined();
|
||||
expect(inputAttributes.autocorrect).toBe('off');
|
||||
expect(inputAttributes.spellcheck).toBe('false');
|
||||
expect(textareaAttributes.autocapitalize).toBe('none');
|
||||
expect(textareaAttributes.autocapitalize).toBeUndefined();
|
||||
expect(textareaAttributes.autocorrect).toBe('off');
|
||||
expect(textareaAttributes.spellcheck).toBe('false');
|
||||
});
|
||||
@@ -62,9 +61,9 @@ describe('inputAutoCap', () => {
|
||||
|
||||
applyNoAutoCapAttributesWithin(root);
|
||||
|
||||
expect(inputAttributes.autocapitalize).toBe('none');
|
||||
expect(inputAttributes.autocapitalize).toBeUndefined();
|
||||
expect(inputAttributes.autocorrect).toBe('off');
|
||||
expect(textareaAttributes.autocapitalize).toBe('none');
|
||||
expect(textareaAttributes.autocapitalize).toBeUndefined();
|
||||
expect(textareaAttributes.autocorrect).toBe('off');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
export const noAutoCapInputProps = {
|
||||
autoCapitalize: 'none' as const,
|
||||
autoCorrect: 'off' as const,
|
||||
spellCheck: false,
|
||||
};
|
||||
@@ -10,7 +9,9 @@ export const applyNoAutoCapAttributes = (element: Element) => {
|
||||
return;
|
||||
}
|
||||
|
||||
element.setAttribute('autocapitalize', 'none');
|
||||
if (typeof element.removeAttribute === 'function') {
|
||||
element.removeAttribute('autocapitalize');
|
||||
}
|
||||
element.setAttribute('autocorrect', 'off');
|
||||
element.setAttribute('spellcheck', 'false');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user