Add a scrollbar to notebook/default textboxes, improve chat scrollbar style #3403
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This lets the "Raw" Textbox in Notebook Mode show a vertical scrollbar when there is enough text. This is a workaround for a Gradio issue (see: gradio-app/gradio#4050, gradio-app/gradio#4044). Tested working on Edge and Chrome.
This is achieved by injecting a simple JavaScript function while creating the Gradio interface and then firing it as soon as the document loads. The same effect could be applied to any UI element by calling
enableScrollBarOnElement
like I do on the raw textbox here.I tried various CSS modifications but Gradio's
scroll-hide
ultimately prevents CSS fixes from working. The scrollbar seems finicky and would not display even if I overrode Gradio's CSS with!important
. So JavaScript was necessary.Before:
![no scrollbar](https://private-user-images.githubusercontent.com/33569918/257643055-6d51b64a-f118-4ea1-9099-6d3c34442670.PNG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgzODY5NDgsIm5iZiI6MTcxODM4NjY0OCwicGF0aCI6Ii8zMzU2OTkxOC8yNTc2NDMwNTUtNmQ1MWI2NGEtZjExOC00ZWExLTkwOTktNmQzYzM0NDQyNjcwLlBORz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE0VDE3MzcyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYwOWNjNzE2NTg3Y2QyZWRmOTcyZTA3MjJjMThjZGEzOWRkM2VhMjg1NWQyODI3MDc1Y2QxN2RlNmI0ZTQyNjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.C7rt8KRDK1DVjbIUellXceqoKdxiV8RMkbU3KtaKdeQ)
After:
![scrollbar](https://private-user-images.githubusercontent.com/33569918/257643067-e5a29ca8-0e81-4607-9c1d-7e39791c9ea4.PNG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTgzODY5NDgsIm5iZiI6MTcxODM4NjY0OCwicGF0aCI6Ii8zMzU2OTkxOC8yNTc2NDMwNjctZTVhMjljYTgtMGU4MS00NjA3LTljMWQtN2UzOTc5MWM5ZWE0LlBORz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjE0VDE3MzcyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTZkODgxMjQyMjZjMjIxZmU0ZjFlMTJkMzg1YmJlZGI4MzA1MzVkMmU0YzZjYWEyZWMzNzRhNDg1OTQzNDRjNDImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.DwWfoz65nvUl6aVmrj0FKhz0Ks6vAcFOHtF6-Vrl5EQ)