mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
feat(request-tabs): prevent browser autoscroll on middle-button mouse actions (#7443)
Added event handlers to prevent the browser's autoscroll behavior when the middle mouse button is pressed in the ExampleTab and RequestTab components. This improves user experience by avoiding unintended scrolling during tab interactions.
This commit is contained in:
@@ -43,6 +43,13 @@ const ExampleTab = ({ tab, collection }) => {
|
||||
}
|
||||
};
|
||||
|
||||
// Prevent the browser's autoscroll (triggered on middle-button mousedown)
|
||||
const handleMouseDown = (e) => {
|
||||
if (e.button === 1) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseUp = (e) => {
|
||||
if (e.button === 1) {
|
||||
e.preventDefault();
|
||||
@@ -59,6 +66,7 @@ const ExampleTab = ({ tab, collection }) => {
|
||||
return (
|
||||
<StyledWrapper
|
||||
className="flex items-center justify-between tab-container"
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseUp={(e) => {
|
||||
if (e.button === 1) {
|
||||
e.preventDefault();
|
||||
@@ -105,6 +113,7 @@ const ExampleTab = ({ tab, collection }) => {
|
||||
className={`flex items-center tab-label ${tab.preview ? 'italic' : ''}`}
|
||||
onContextMenu={handleRightClick}
|
||||
onDoubleClick={() => dispatch(makeTabPermanent({ uid: tab.uid }))}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseUp={(e) => {
|
||||
if (!hasChanges) return handleMouseUp(e);
|
||||
|
||||
|
||||
@@ -103,6 +103,13 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi
|
||||
menuDropdownRef.current?.show();
|
||||
};
|
||||
|
||||
// Prevent the browser's autoscroll (triggered on middle-button mousedown)
|
||||
const handleMouseDown = (e) => {
|
||||
if (e.button === 1) {
|
||||
e.preventDefault();
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseUp = (e) => {
|
||||
if (e.button === 1) {
|
||||
e.preventDefault();
|
||||
@@ -260,6 +267,7 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi
|
||||
return (
|
||||
<StyledWrapper
|
||||
className={`flex items-center justify-between tab-container px-2 ${tab.preview ? 'italic' : ''}`}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseUp={handleMouseUp}
|
||||
>
|
||||
{showConfirmCollectionClose && tab.type === 'collection-settings' && (
|
||||
@@ -447,6 +455,7 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi
|
||||
return (
|
||||
<StyledWrapper
|
||||
className="flex items-center justify-between tab-container"
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseUp={(e) => {
|
||||
if (e.button === 1) {
|
||||
e.preventDefault();
|
||||
@@ -503,6 +512,7 @@ const RequestTab = ({ tab, collection, tabIndex, collectionRequestTabs, folderUi
|
||||
className={`flex items-baseline tab-label ${tab.preview ? 'italic' : ''}`}
|
||||
onContextMenu={handleRightClick}
|
||||
onDoubleClick={() => dispatch(makeTabPermanent({ uid: tab.uid }))}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseUp={(e) => {
|
||||
if (!hasChanges) return handleMouseUp(e);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user