Enhancement: Make buttons scrollable

b1b6f0473a2c20eea0fdab39620875c517485a18

Joe <joenunezb@gmail.com>

1 files changed, +35 -2Ignore whitespace
public/scripts/slash-commands.js+35 -2
@@ -2074,7 +2074,32 @@ async function buttonsCallback(args, text) {
20742074 let popup;
20752075
20762076 const buttonContainer = document.createElement('div');
20772077 buttonContainer.classList.add('flex-container', 'flexFlowColumn', 'wide100p', 'm-t-1');
2078+
2079+ const scrollableContainer = document.createElement('div');
2080+ scrollableContainer.style.maxHeight = '50vh'; // Use viewport height instead of fixed pixels
2081+ scrollableContainer.style.overflowY = 'auto';
2082+ scrollableContainer.style.WebkitOverflowScrolling = 'touch'; // Enable momentum scrolling on iOS
2083+ scrollableContainer.classList.add('m-t-1', 'scrollable-buttons');
2084+
2085+ // Add custom CSS for better mobile scrolling
2086+ const style = document.createElement('style');
2087+ style.textContent = `
2088+ .scrollable-buttons {
2089+ -webkit-overflow-scrolling: touch;
2090+ overflow-y: auto;
2091+ flex-shrink: 1;
2092+ min-height: 0;
2093+ }
2094+ .scrollable-buttons::-webkit-scrollbar {
2095+ width: 6px;
2096+ }
2097+ .scrollable-buttons::-webkit-scrollbar-thumb {
2098+ background-color: rgba(0, 0, 0, 0.2);
2099+ border-radius: 3px;
2100+ }
2101+ `;
2102+ document.head.appendChild(style);
20782103
20792104 for (const [result, button] of resultToButtonMap) {
20802105 const buttonElement = document.createElement('div');
@@ -2087,9 +2112,16 @@ async function buttonsCallback(args, text) {
20872112 buttonContainer.appendChild(buttonElement);
20882113 }
20892114
2115+ scrollableContainer.appendChild(buttonContainer);
2116+
20902117 const popupContainer = document.createElement('div');
20912118 popupContainer.innerHTML = safeValue;
20922119 popupContainer.appendChild(buttonContainerscrollableContainer);
2120+
2121+ // Ensure the popup uses flex layout
2122+ popupContainer.style.display = 'flex';
2123+ popupContainer.style.flexDirection = 'column';
2124+ popupContainer.style.maxHeight = '80vh'; // Limit the overall height of the popup
20932125
20942126 popup = new Popup(popupContainer, POPUP_TYPE.TEXT, '', { okButton: 'Cancel' });
20952127 popup.show()
@@ -4272,3 +4304,4 @@ sendTextarea.addEventListener('input', () => {
42724304 sendTextarea.style.fontFamily = null;
42734305 }
42744306});
4307+