fix(web): stop prompt font size changing on window resize (#2103)
Co-authored-by: Kandev Agent <agent@kandev.dev>
This commit is contained in:
@@ -9,10 +9,20 @@ import * as tiptapEditor from "./use-tiptap-editor";
|
||||
import { decideHistoryNav } from "./tiptap-editor-history";
|
||||
|
||||
describe("TIPTAP_EDITOR_TEXT_SIZE_CLASS", () => {
|
||||
it("keeps 16px text until the lg breakpoint", () => {
|
||||
expect(TIPTAP_EDITOR_TEXT_SIZE_CLASS).toContain("text-base");
|
||||
expect(TIPTAP_EDITOR_TEXT_SIZE_CLASS).toContain("lg:text-sm");
|
||||
expect(TIPTAP_EDITOR_TEXT_SIZE_CLASS).not.toContain("md:text-sm");
|
||||
it("uses one text size at every viewport width", () => {
|
||||
expect(TIPTAP_EDITOR_TEXT_SIZE_CLASS).toContain("text-sm");
|
||||
expect(TIPTAP_EDITOR_TEXT_SIZE_CLASS).not.toContain("text-base");
|
||||
});
|
||||
|
||||
it("carries no variant-prefixed text utility, so resizing cannot change the font", () => {
|
||||
// The touch 16px floor lives in the `any-pointer: coarse` rule in
|
||||
// globals.css; a width breakpoint here would resize the composer text when
|
||||
// a desktop window is dragged narrow. Reject *any* `<variant>:text-*`
|
||||
// rather than a list of named breakpoints — an arbitrary variant such as
|
||||
// `min-[1024px]:text-lg` or `max-[900px]:text-base` is just as
|
||||
// viewport-dependent and would slip past an enumerated pattern.
|
||||
const variantTextUtility = /(?:^|\s)\S+:text-\S+/;
|
||||
expect(TIPTAP_EDITOR_TEXT_SIZE_CLASS).not.toMatch(variantTextUtility);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -51,7 +51,14 @@ export type TipTapInputHandle = {
|
||||
};
|
||||
|
||||
const lowlightInstance = createLowlight(common);
|
||||
export const TIPTAP_EDITOR_TEXT_SIZE_CLASS = "text-base leading-relaxed lg:text-sm";
|
||||
/** Viewport-width-independent on purpose. The 16px floor that stops iOS Safari
|
||||
* from auto-zooming a focused field is owned by the `@media (any-pointer:
|
||||
* coarse)` rule in `app/globals.css`, which is keyed on the input device
|
||||
* rather than the window size. A width breakpoint here (the old
|
||||
* `text-base … lg:text-sm`) made the composer text jump from 14px to 16px when
|
||||
* a desktop window was dragged narrower than `lg`, which is not a touch
|
||||
* device and needs no zoom guard. */
|
||||
export const TIPTAP_EDITOR_TEXT_SIZE_CLASS = "text-sm leading-relaxed";
|
||||
|
||||
type UseTipTapEditorOptions = {
|
||||
value: string;
|
||||
|
||||
Reference in New Issue
Block a user