Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Fix scroll behaviour in space panel #8109

Closed
wants to merge 4 commits into from
Closed
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
35 changes: 28 additions & 7 deletions res/css/structures/_LeftPanel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,41 @@ $roomListCollapsedWidth: 68px;
}
}

.mx_LeftPanel_outerWrapper {
.mx_LeftPanel_wrapper {
display: flex;
flex-direction: column;
max-width: 50%;
position: relative;

// Contain the amount of layers rendered by constraining what actually needs re-layering via css
contain: layout paint;
}

.mx_LeftPanel_wrapper {
display: flex;
flex-direction: row;
flex: 1;
&:has(.mx_LeftPanelLiveShareWarning) {
top: 10px;
}

.mx_LeftPanelLiveShareWarning {
position: absolute; // sit in the padding the left panel will make for us
top: 0;
z-index: 10; // above backdrops

// Fill the left panel
width: 100%;
box-sizing: border-box;

padding: $spacing-4;
text-align: center;

background-color: $accent;
color: #fff;
font-size: $font-10px;
}

// Until we have `:has()` selectors... this will have to do
&.mx_LeftPanel_wrapperWithLocshare {
// Create a gap for the LiveShareWarning to sit.
// content height + padding top + padding bottom
padding-top: calc($font-10px + $spacing-4 + $spacing-4);
}

.mx_LeftPanel_wrapper--user {
background-color: $roomlist-bg-color;
Expand Down
2 changes: 1 addition & 1 deletion res/css/structures/_MatrixChat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ limitations under the License.
}

/* not the left panel, and not the resize handle, so the roomview/groupview/... */
.mx_MatrixChat > :not(.mx_LeftPanel):not(.mx_SpacePanel):not(.mx_ResizeHandle):not(.mx_LeftPanel_outerWrapper) {
.mx_MatrixChat > :not(.mx_LeftPanel):not(.mx_SpacePanel):not(.mx_ResizeHandle):not(.mx_LeftPanel_wrapper) {
background-color: $background;

flex: 1 1 0;
Expand Down
71 changes: 48 additions & 23 deletions src/components/structures/LoggedInView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ import { TimelineRenderingType } from "../../contexts/RoomContext";
import { KeyBindingAction } from "../../accessibility/KeyboardShortcuts";
import { SwitchSpacePayload } from "../../dispatcher/payloads/SwitchSpacePayload";
import { IConfigOptions } from "../../IConfigOptions";
import LeftPanelLiveShareWarning from '../views/beacon/LeftPanelLiveShareWarning';
import { OwnBeaconStore, OwnBeaconStoreEvent } from "../../stores/OwnBeaconStore";
import { _t } from "../../languageHandler";
import { Icon as LiveLocationIcon } from "../../../res/img/location/live-location.svg";

// We need to fetch each pinned message individually (if we don't already have it)
// so each pinned message may trigger a request. Limit the number per room for sanity.
Expand Down Expand Up @@ -121,6 +123,7 @@ interface IState {
useCompactLayout: boolean;
activeCalls: Array<MatrixCall>;
backgroundImage?: string;
isSharingLiveLocation?: boolean;
}

/**
Expand Down Expand Up @@ -195,6 +198,8 @@ class LoggedInView extends React.Component<IProps, IState> {
this.resizer = this.createResizer();
this.resizer.attach();

OwnBeaconStore.instance.on(OwnBeaconStoreEvent.LivenessChange, this.onBeaconUpdate);

OwnProfileStore.instance.on(UPDATE_EVENT, this.refreshBackgroundImage);
this.loadResizerPreferences();
this.refreshBackgroundImage();
Expand All @@ -210,9 +215,16 @@ class LoggedInView extends React.Component<IProps, IState> {
SettingsStore.unwatchSetting(this.layoutWatcherRef);
SettingsStore.unwatchSetting(this.compactLayoutWatcherRef);
SettingsStore.unwatchSetting(this.backgroundImageWatcherRef);
OwnBeaconStore.instance.off(OwnBeaconStoreEvent.LivenessChange, this.onBeaconUpdate);
this.resizer.detach();
}

private onBeaconUpdate = () => {
this.setState({
isSharingLiveLocation: OwnBeaconStore.instance.hasLiveBeacons(),
});
};

private onCallState = (): void => {
const activeCalls = CallHandler.instance.getAllActiveCalls();
if (activeCalls === this.state.activeCalls) return;
Expand Down Expand Up @@ -681,6 +693,7 @@ class LoggedInView extends React.Component<IProps, IState> {
);
});

const isMinimized = this.props.collapseLhs || false;
return (
<MatrixClientContext.Provider value={this._matrixClient}>
<div
Expand All @@ -691,10 +704,23 @@ class LoggedInView extends React.Component<IProps, IState> {
>
<ToastContainer />
<div className={bodyClasses}>
<div className='mx_LeftPanel_outerWrapper'>
<LeftPanelLiveShareWarning isMinimized={this.props.collapseLhs || false} />
<div className='mx_LeftPanel_wrapper'>
{ SettingsStore.getValue('TagPanel.enableTagPanel') &&
<div className={classNames("mx_LeftPanel_wrapper", {
"mx_LeftPanel_wrapperWithLocshare": this.state.isSharingLiveLocation,
})}>
{ this.state.isSharingLiveLocation
? <div
className={classNames('mx_LeftPanelLiveShareWarning', {
'mx_LeftPanelLiveShareWarning__minimized': isMinimized,
})}
title={isMinimized ? _t('You are sharing your live location') : undefined}
>
{ isMinimized
? <LiveLocationIcon height={10} />
: _t('You are sharing your live location')
}
</div> : null
}
{ SettingsStore.getValue('TagPanel.enableTagPanel') &&
(<div className="mx_GroupFilterPanelContainer">
<BackdropPanel
blurMultiplier={0.5}
Expand All @@ -703,27 +729,26 @@ class LoggedInView extends React.Component<IProps, IState> {
<GroupFilterPanel />
{ SettingsStore.getValue("feature_custom_tags") ? <CustomRoomTagPanel /> : null }
</div>)
}
{ SpaceStore.spacesEnabled ? <>
<BackdropPanel
blurMultiplier={0.5}
backgroundImage={this.state.backgroundImage}
/>
<SpacePanel />
</> : null }
}
{ SpaceStore.spacesEnabled ? <>
<BackdropPanel
blurMultiplier={0.5}
backgroundImage={this.state.backgroundImage}
/>
<div
className="mx_LeftPanel_wrapper--user"
ref={this._resizeContainer}
data-collapsed={this.props.collapseLhs ? true : undefined}
>
<LeftPanel
isMinimized={this.props.collapseLhs || false}
resizeNotifier={this.props.resizeNotifier}
/>
</div>
<SpacePanel />
</> : null }
<BackdropPanel
backgroundImage={this.state.backgroundImage}
/>
<div
className="mx_LeftPanel_wrapper--user"
ref={this._resizeContainer}
data-collapsed={this.props.collapseLhs ? true : undefined}
>
<LeftPanel
isMinimized={this.props.collapseLhs || false}
resizeNotifier={this.props.resizeNotifier}
/>
</div>
</div>
<ResizeHandle passRef={this.resizeHandler} id="lp-resizer" />
Expand Down
50 changes: 0 additions & 50 deletions src/components/views/beacon/LeftPanelLiveShareWarning.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/i18n/strings/en_EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -2964,7 +2964,6 @@
"Beta": "Beta",
"Leave the beta": "Leave the beta",
"Join the beta": "Join the beta",
"You are sharing your live location": "You are sharing your live location",
"Avatar": "Avatar",
"This room is public": "This room is public",
"Away": "Away",
Expand Down Expand Up @@ -3084,6 +3083,7 @@
"Private community": "Private community",
"To view %(communityName)s, swap to communities in your <a>preferences</a>": "To view %(communityName)s, swap to communities in your <a>preferences</a>",
"To join %(communityName)s, swap to communities in your <a>preferences</a>": "To join %(communityName)s, swap to communities in your <a>preferences</a>",
"You are sharing your live location": "You are sharing your live location",
"Wait!": "Wait!",
"If someone told you to copy/paste something here, there is a high likelihood you're being scammed!": "If someone told you to copy/paste something here, there is a high likelihood you're being scammed!",
"If you know what you're doing, Element is open-source, be sure to check out our GitHub (https://github.com/vector-im/element-web/) and contribute!": "If you know what you're doing, Element is open-source, be sure to check out our GitHub (https://github.com/vector-im/element-web/) and contribute!",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import React from 'react';
import { mocked } from 'jest-mock';
import { mount } from 'enzyme';

import '../../../skinned-sdk';
import LeftPanelLiveShareWarning from '../../../../src/components/views/beacon/LeftPanelLiveShareWarning';
import { OwnBeaconStore, OwnBeaconStoreEvent } from '../../../../src/stores/OwnBeaconStore';
import { flushPromises } from '../../../test-utils';

Expand All @@ -39,10 +37,13 @@ jest.mock('../../../../src/stores/OwnBeaconStore', () => {
},
);

describe('<LeftPanelLiveShareWarning />', () => {
const defaultProps = {};
// TODO: Restore component and re-enable test
// See https://github.com/vector-im/element-web/issues/21506
describe.skip('<LeftPanelLiveShareWarning />', () => {
const getComponent = (props = {}) =>
mount(<LeftPanelLiveShareWarning {...defaultProps} {...props} />);
// TODO: Re-enable with above
//mount(<LeftPanelLiveShareWarning {...defaultProps} {...props} />);
mount(null);

it('renders nothing when user has no live beacons', () => {
const component = getComponent();
Expand Down