Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { objectKeys } from "@appsmith/utils";
import type { Theme } from "../../theme";
import type { ThemeToken, Typography } from "../../token";
import { cssRule, getTypographyClassName } from "../../utils";
import { getScrollbarWidth } from "@appsmith/utils";

const fontFamilyCss = () => {
const fontFamilyCss =
Expand Down Expand Up @@ -91,11 +92,18 @@ export function useCssTokens(props: Theme) {
}
}, [colorMode]);

const scrollbarWidthClassName = useMemo(() => {
return css`
--scrollbar-width: ${getScrollbarWidth()}px;
`;
}, []);

return {
colorClassName,
colorModeClassName,
fontFamilyClassName,
typographyClassName,
providerClassName,
scrollbarWidthClassName,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const ThemeProvider = (props: ThemeProviderProps) => {
colorModeClassName,
fontFamilyClassName,
providerClassName,
scrollbarWidthClassName,
typographyClassName,
} = useCssTokens(theme);

Expand All @@ -32,6 +33,7 @@ export const ThemeProvider = (props: ThemeProviderProps) => {
fontFamilyClassName,
providerClassName,
typographyClassName,
scrollbarWidthClassName,
)}
data-theme-provider=""
ref={providerRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
margin-block: var(--inner-spacing-1);
}

.inputGroup:has([data-has-scrollbar]):has(.input:is(textarea))
[data-input-suffix] {
right: calc(var(--sizing-1) + var(--scrollbar-width));
}

.input:autofill,
.input:autofill:hover,
.input:autofill:focus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@ export function TextArea(props: TextAreaProps) {

setTextFieldHeight(height + marginTop + marginBottom);

input.style.height = `${input.scrollHeight}px`;
input.style.height = `${input.scrollHeight + 1}px`;
Copy link
Contributor Author

@jsartisan jsartisan Mar 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

had to add 1px here, there was a weird scrollbar bug happening without it.

CleanShot.2025-03-05.at.12.28.44.mp4

input.style.overflow = prevOverflow;
input.style.alignSelf = prevAlignment;

if (input.scrollHeight > input.clientHeight) {
input.setAttribute("data-has-scrollbar", "true");
} else {
input.removeAttribute("data-has-scrollbar");
}
}
}, [props.height]);

Expand Down
15 changes: 15 additions & 0 deletions app/client/packages/utils/src/dom/getScrollbarWidth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const getScrollbarWidth = () => {
const scrollDiv = document.createElement("div");

scrollDiv.setAttribute(
"style",
"width: 100px; height: 100px; overflow: scroll; position:absolute; top:-9999px;",
);
document.body.appendChild(scrollDiv);

const scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;

document.body.removeChild(scrollDiv);

return scrollbarWidth;
};
1 change: 1 addition & 0 deletions app/client/packages/utils/src/dom/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { getScrollbarWidth } from "./getScrollbarWidth";
1 change: 1 addition & 0 deletions app/client/packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from "./file";
export * from "./object";
export * from "./url";
export * from "./validateApiPath";
export * from "./dom";
Loading