don't force height if the height can't change (no children edge)

pull/21833/head
Michael Telatynski 2021-07-21 10:39:04 +01:00
parent bc87dc3c56
commit 880dc26847
2 changed files with 16 additions and 9 deletions

View File

@ -24,11 +24,14 @@ limitations under the License.
.mx_LeaveSpaceDialog { .mx_LeaveSpaceDialog {
width: 440px; width: 440px;
height: 500px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex-wrap: nowrap; flex-wrap: nowrap;
&.mx_LeaveSpaceDialog_hasChildren {
height: 500px;
}
.mx_Dialog_content { .mx_Dialog_content {
flex-grow: 1; flex-grow: 1;
margin: 0 0 24px; margin: 0 0 24px;

View File

@ -27,6 +27,7 @@ import AutoHideScrollbar from "../../structures/AutoHideScrollbar";
import { Entry } from "./AddExistingToSpaceDialog"; import { Entry } from "./AddExistingToSpaceDialog";
import SearchBox from "../../structures/SearchBox"; import SearchBox from "../../structures/SearchBox";
import QueryMatcher from "../../../autocomplete/QueryMatcher"; import QueryMatcher from "../../../autocomplete/QueryMatcher";
import classNames from "classnames";
enum RoomsToLeave { enum RoomsToLeave {
All = "All", All = "All",
@ -78,9 +79,8 @@ const SpaceChildPicker = ({ filterPlaceholder, rooms, selected, onChange }) => {
</div>; </div>;
}; };
const LeaveRoomsPicker = ({ space, roomsToLeave, setRoomsToLeave }) => { const LeaveRoomsPicker = ({ space, spaceChildren, roomsToLeave, setRoomsToLeave }) => {
const selected = useMemo(() => new Set(roomsToLeave), [roomsToLeave]); const selected = useMemo(() => new Set(roomsToLeave), [roomsToLeave]);
const spaceChildren = useMemo(() => SpaceStore.instance.getChildren(space.roomId), [space.roomId]);
const [state, setState] = useState<RoomsToLeave>(RoomsToLeave.All); const [state, setState] = useState<RoomsToLeave>(RoomsToLeave.All);
useEffect(() => { useEffect(() => {
@ -108,10 +108,6 @@ const LeaveRoomsPicker = ({ space, roomsToLeave, setRoomsToLeave }) => {
break; break;
} }
if (spaceChildren.length < 1) {
return null;
}
return <div className="mx_LeaveSpaceDialog_section"> return <div className="mx_LeaveSpaceDialog_section">
<Dropdown <Dropdown
id="mx_LeaveSpaceDialog_leaveRoomPickerDropdown" id="mx_LeaveSpaceDialog_leaveRoomPickerDropdown"
@ -160,6 +156,7 @@ const isOnlyAdmin = (room: Room): boolean => {
}; };
const LeaveSpaceDialog: React.FC<IProps> = ({ space, onFinished }) => { const LeaveSpaceDialog: React.FC<IProps> = ({ space, onFinished }) => {
const spaceChildren = useMemo(() => SpaceStore.instance.getChildren(space.roomId), [space.roomId]);
const [roomsToLeave, setRoomsToLeave] = useState<Room[]>([]); const [roomsToLeave, setRoomsToLeave] = useState<Room[]>([]);
let rejoinWarning; let rejoinWarning;
@ -181,7 +178,9 @@ const LeaveSpaceDialog: React.FC<IProps> = ({ space, onFinished }) => {
return <BaseDialog return <BaseDialog
title={_t("Leave %(spaceName)s", { spaceName: space.name })} title={_t("Leave %(spaceName)s", { spaceName: space.name })}
className="mx_LeaveSpaceDialog" className={classNames("mx_LeaveSpaceDialog", {
mx_LeaveSpaceDialog_hasChildren: spaceChildren.length > 0,
})}
contentId="mx_LeaveSpaceDialog" contentId="mx_LeaveSpaceDialog"
onFinished={() => onFinished(false)} onFinished={() => onFinished(false)}
fixedWidth={false} fixedWidth={false}
@ -195,7 +194,12 @@ const LeaveSpaceDialog: React.FC<IProps> = ({ space, onFinished }) => {
{ rejoinWarning } { rejoinWarning }
</p> </p>
<LeaveRoomsPicker space={space} roomsToLeave={roomsToLeave} setRoomsToLeave={setRoomsToLeave} /> { spaceChildren.length > 0 && <LeaveRoomsPicker
space={space}
spaceChildren={spaceChildren}
roomsToLeave={roomsToLeave}
setRoomsToLeave={setRoomsToLeave}
/> }
{ onlyAdminWarning && <div className="mx_LeaveSpaceDialog_section_warning"> { onlyAdminWarning && <div className="mx_LeaveSpaceDialog_section_warning">
{ onlyAdminWarning } { onlyAdminWarning }