Park up changes

This commit is contained in:
Half-Shot 2026-05-12 12:31:21 +01:00
parent 0c3429a5d1
commit c569e8914a
9 changed files with 259 additions and 173 deletions

View File

@ -31,17 +31,23 @@ export default class Measured extends React.PureComponent<IProps> {
}
public componentDidMount(): void {
console.log("Measured componentDidMount", this.props.sensor.current);
if (this.props.sensor.current) {
UIStore.instance.trackElementDimensions(`Measured${this.instanceId}`, this.props.sensor.current);
}
UIStore.instance.on(`Measured${this.instanceId}`, this.onResize);
}
public componentDidUpdate(prevProps: Readonly<IProps>): void {
const previous = prevProps.sensor.current;
const current = this.props.sensor.current;
console.log("Measured componentDidUpdate", current);
if (previous === current) return;
if (previous) {
UIStore.instance.stopTrackingElementDimensions(`Measured${this.instanceId}`);
}
if (current) {
console.log("Measured trackElementDimensions");
UIStore.instance.trackElementDimensions(`Measured${this.instanceId}`, current);
}
}

View File

@ -88,6 +88,7 @@ export default class UIStore extends EventEmitter {
entries.forEach((entry) => {
const trackedElementName = this.trackedUiElements.get(entry.target);
if (trackedElementName) {
console.log("resizeObserverCallback for tracked", trackedElementName);
this.uiElementDimensions.set(trackedElementName, entry.contentRect);
this.emit(trackedElementName, UI_EVENTS.Resize, entry);
}

View File

@ -229,7 +229,6 @@ export function RoomUploadContextProvider({
});
useEffect(() => {
console.log("Reply to event!", replyToEvent);
vm.setReplyToEvent(replyToEvent);
}, [vm, replyToEvent]);

View File

@ -212,7 +212,7 @@ exports[`RoomView for a local room in state ERROR should match the snapshot 1`]
</div>
</div>
<div
aria-labelledby="_r_1cl_"
aria-labelledby="_r_1dt_"
class="_banner_n7ud0_8"
data-type="critical"
role="status"
@ -238,7 +238,7 @@ exports[`RoomView for a local room in state ERROR should match the snapshot 1`]
>
<p
class="_typography_6v6n8_153 _font-body-md-medium_6v6n8_60 _title_mcq5y_24"
id="_r_1cl_"
id="_r_1dt_"
>
Could not start a chat with this user
</p>
@ -423,7 +423,7 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] =
>
<svg
aria-label="Messages in this room are not end-to-end encrypted"
aria-labelledby="_r_19j_"
aria-labelledby="_r_1an_"
class="mx_E2EIcon mx_MessageComposer_e2eIcon"
color="var(--cpd-color-icon-info-primary)"
fill="currentColor"
@ -608,24 +608,32 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] =
/>
</svg>
</div>
<div
aria-label="Attachment"
class="mx_AccessibleButton mx_MessageComposer_button"
<button
aria-labelledby="_r_1bs_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Attachment"
>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
<div
class="_indicator-icon_147l5_17"
style="--cpd-icon-button-size: 100%;"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
</button>
<div
aria-label="More options"
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"
@ -702,7 +710,7 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
</span>
<svg
aria-label="New members see history"
aria-labelledby="_r_1cf_"
aria-labelledby="_r_1dn_"
class="mx_RoomHeader_icon"
color="var(--cpd-color-icon-info-primary)"
fill="currentColor"
@ -981,24 +989,32 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
/>
</svg>
</div>
<div
aria-label="Attachment"
class="mx_AccessibleButton mx_MessageComposer_button"
<button
aria-labelledby="_r_1dc_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Attachment"
>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
<div
class="_indicator-icon_147l5_17"
style="--cpd-icon-button-size: 100%;"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
</button>
<div
aria-label="More options"
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"
@ -1599,24 +1615,32 @@ exports[`RoomView should hide the header when hideHeader=true 1`] = `
/>
</svg>
</div>
<div
aria-label="Attachment"
class="mx_AccessibleButton mx_MessageComposer_button"
<button
aria-labelledby="_r_27_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Attachment"
>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
<div
class="_indicator-icon_147l5_17"
style="--cpd-icon-button-size: 100%;"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
</button>
<div
aria-label="More options"
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"
@ -1724,7 +1748,7 @@ exports[`RoomView should hide the pinned message banner when hidePinnedMessageBa
style="--cpd-icon-button-size: 100%;"
>
<svg
aria-labelledby="_r_5e_"
aria-labelledby="_r_5i_"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@ -1751,7 +1775,7 @@ exports[`RoomView should hide the pinned message banner when hidePinnedMessageBa
style="--cpd-icon-button-size: 100%;"
>
<svg
aria-labelledby="_r_5j_"
aria-labelledby="_r_5n_"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@ -1766,7 +1790,7 @@ exports[`RoomView should hide the pinned message banner when hidePinnedMessageBa
</button>
<button
aria-label="Threads"
aria-labelledby="_r_5o_"
aria-labelledby="_r_5s_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -1793,7 +1817,7 @@ exports[`RoomView should hide the pinned message banner when hidePinnedMessageBa
</button>
<button
aria-label="Room info"
aria-labelledby="_r_5t_"
aria-labelledby="_r_61_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -1823,7 +1847,7 @@ exports[`RoomView should hide the pinned message banner when hidePinnedMessageBa
>
<div
aria-label="0 members"
aria-labelledby="_r_62_"
aria-labelledby="_r_66_"
class="mx_AccessibleButton mx_FacePile"
role="button"
tabindex="0"
@ -1890,7 +1914,7 @@ exports[`RoomView should hide the pinned message banner when hidePinnedMessageBa
>
<svg
aria-label="Messages in this room are not end-to-end encrypted"
aria-labelledby="_r_6e_"
aria-labelledby="_r_6i_"
class="mx_E2EIcon mx_MessageComposer_e2eIcon"
color="var(--cpd-color-icon-info-primary)"
fill="currentColor"
@ -2075,24 +2099,32 @@ exports[`RoomView should hide the pinned message banner when hidePinnedMessageBa
/>
</svg>
</div>
<div
aria-label="Attachment"
class="mx_AccessibleButton mx_MessageComposer_button"
<button
aria-labelledby="_r_7n_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Attachment"
>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
<div
class="_indicator-icon_147l5_17"
style="--cpd-icon-button-size: 100%;"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
</button>
<div
aria-label="More options"
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"
@ -2200,7 +2232,7 @@ exports[`RoomView should hide the right panel when hideRightPanel=true 1`] = `
style="--cpd-icon-button-size: 100%;"
>
<svg
aria-labelledby="_r_2g_"
aria-labelledby="_r_2i_"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@ -2227,7 +2259,7 @@ exports[`RoomView should hide the right panel when hideRightPanel=true 1`] = `
style="--cpd-icon-button-size: 100%;"
>
<svg
aria-labelledby="_r_2l_"
aria-labelledby="_r_2n_"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@ -2242,7 +2274,7 @@ exports[`RoomView should hide the right panel when hideRightPanel=true 1`] = `
</button>
<button
aria-label="Threads"
aria-labelledby="_r_2q_"
aria-labelledby="_r_2s_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -2269,7 +2301,7 @@ exports[`RoomView should hide the right panel when hideRightPanel=true 1`] = `
</button>
<button
aria-label="Room info"
aria-labelledby="_r_2v_"
aria-labelledby="_r_31_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -2299,7 +2331,7 @@ exports[`RoomView should hide the right panel when hideRightPanel=true 1`] = `
>
<div
aria-label="0 members"
aria-labelledby="_r_34_"
aria-labelledby="_r_36_"
class="mx_AccessibleButton mx_FacePile mx_FacePile_toggled"
role="button"
tabindex="0"
@ -2366,7 +2398,7 @@ exports[`RoomView should hide the right panel when hideRightPanel=true 1`] = `
>
<svg
aria-label="Messages in this room are not end-to-end encrypted"
aria-labelledby="_r_3g_"
aria-labelledby="_r_3i_"
class="mx_E2EIcon mx_MessageComposer_e2eIcon"
color="var(--cpd-color-icon-info-primary)"
fill="currentColor"
@ -2551,24 +2583,32 @@ exports[`RoomView should hide the right panel when hideRightPanel=true 1`] = `
/>
</svg>
</div>
<div
aria-label="Attachment"
class="mx_AccessibleButton mx_MessageComposer_button"
<button
aria-labelledby="_r_4n_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Attachment"
>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
<div
class="_indicator-icon_147l5_17"
style="--cpd-icon-button-size: 100%;"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
</button>
<div
aria-label="More options"
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"
@ -2676,7 +2716,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
style="--cpd-icon-button-size: 100%;"
>
<svg
aria-labelledby="_r_fc_"
aria-labelledby="_r_fo_"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@ -2703,7 +2743,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
style="--cpd-icon-button-size: 100%;"
>
<svg
aria-labelledby="_r_fh_"
aria-labelledby="_r_ft_"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@ -2718,7 +2758,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
</button>
<button
aria-label="Threads"
aria-labelledby="_r_fm_"
aria-labelledby="_r_g2_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -2745,7 +2785,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
</button>
<button
aria-label="Room info"
aria-labelledby="_r_fr_"
aria-labelledby="_r_g7_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -2775,7 +2815,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
>
<div
aria-label="0 members"
aria-labelledby="_r_g0_"
aria-labelledby="_r_gc_"
class="mx_AccessibleButton mx_FacePile"
role="button"
tabindex="0"
@ -2881,7 +2921,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
</span>
<svg
aria-label="New members see history"
aria-labelledby="_r_gc_"
aria-labelledby="_r_go_"
class="mx_RoomHeader_icon"
color="var(--cpd-color-icon-info-primary)"
fill="currentColor"
@ -2914,7 +2954,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
style="--cpd-icon-button-size: 100%;"
>
<svg
aria-labelledby="_r_fc_"
aria-labelledby="_r_fo_"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@ -2941,7 +2981,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
style="--cpd-icon-button-size: 100%;"
>
<svg
aria-labelledby="_r_fh_"
aria-labelledby="_r_ft_"
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
@ -2956,7 +2996,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
</button>
<button
aria-label="Threads"
aria-labelledby="_r_fm_"
aria-labelledby="_r_g2_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -2983,7 +3023,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
</button>
<button
aria-label="Room info"
aria-labelledby="_r_fr_"
aria-labelledby="_r_g7_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -3013,7 +3053,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
>
<div
aria-label="0 members"
aria-labelledby="_r_g0_"
aria-labelledby="_r_gc_"
class="mx_AccessibleButton mx_FacePile"
role="button"
tabindex="0"
@ -3082,7 +3122,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
tabindex="0"
>
<div
aria-labelledby="_r_gh_"
aria-labelledby="_r_gt_"
class="mx_E2EIcon mx_MessageComposer_e2eIcon"
data-testid="e2e-icon"
style="width: 12px; height: 12px;"
@ -3275,24 +3315,32 @@ exports[`RoomView should not display the timeline when the room encryption is lo
/>
</svg>
</div>
<div
aria-label="Attachment"
class="mx_AccessibleButton mx_MessageComposer_button"
<button
aria-labelledby="_r_i2_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Attachment"
>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
<div
class="_indicator-icon_147l5_17"
style="--cpd-icon-button-size: 100%;"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
</button>
<div
aria-label="More options"
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"
@ -3418,7 +3466,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
</button>
<button
aria-label="Chat"
aria-labelledby="_r_ks_"
aria-labelledby="_r_lc_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -3445,7 +3493,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
</button>
<button
aria-label="Threads"
aria-labelledby="_r_l1_"
aria-labelledby="_r_lh_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -3472,7 +3520,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
</button>
<button
aria-label="Room info"
aria-labelledby="_r_l6_"
aria-labelledby="_r_lm_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
@ -3502,7 +3550,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
>
<div
aria-label="0 members"
aria-labelledby="_r_lb_"
aria-labelledby="_r_lr_"
class="mx_AccessibleButton mx_FacePile"
role="button"
tabindex="0"
@ -3587,7 +3635,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
</p>
</div>
<button
aria-labelledby="_r_lk_"
aria-labelledby="_r_m4_"
class="_icon-button_1215g_8"
data-kind="secondary"
data-testid="base-card-close-button"
@ -3647,7 +3695,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
>
<svg
aria-label="Messages in this room are not end-to-end encrypted"
aria-labelledby="_r_lp_"
aria-labelledby="_r_m9_"
class="mx_E2EIcon mx_MessageComposer_e2eIcon"
color="var(--cpd-color-icon-info-primary)"
fill="currentColor"
@ -3832,24 +3880,32 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
/>
</svg>
</div>
<div
aria-label="Attachment"
class="mx_AccessibleButton mx_MessageComposer_button"
<button
aria-labelledby="_r_ne_"
class="_icon-button_1215g_8"
data-kind="primary"
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Attachment"
>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
<div
class="_indicator-icon_147l5_17"
style="--cpd-icon-button-size: 100%;"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
<svg
fill="currentColor"
height="1em"
viewBox="0 0 24 24"
width="1em"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.5 22q-2.3 0-3.9-1.6T6 16.5V6q0-1.65 1.175-2.825T10 2t2.825 1.175T14 6v9.5q0 1.05-.725 1.775T11.5 18t-1.775-.725T9 15.5V6.75A.73.73 0 0 1 9.75 6a.73.73 0 0 1 .75.75v8.75q0 .424.287.712.288.288.713.288.424 0 .713-.288a.97.97 0 0 0 .287-.712V6q0-1.05-.725-1.775T10 3.5t-1.775.725T7.5 6v10.5q0 1.65 1.175 2.825T11.5 20.5t2.825-1.175T15.5 16.5V6.75a.73.73 0 0 1 .75-.75.73.73 0 0 1 .75.75v9.75q0 2.3-1.6 3.9T11.5 22"
/>
</svg>
</div>
</button>
<div
aria-label="More options"
class="mx_AccessibleButton mx_MessageComposer_button mx_MessageComposer_buttonMenu"

View File

@ -6,7 +6,7 @@
*/
import React, { type JSX } from "react";
import { type Meta, type StoryFn } from "@storybook/react-vite";
import { type StoryObj, type Meta } from "@storybook/react-vite";
import { fn } from "storybook/test";
import { AttachmentIcon, ReactionIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
@ -16,22 +16,49 @@ import { withViewDocs } from "../../../../.storybook/withViewDocs";
const UploadButtonWrapperImpl = ({
onUploadOptionSelected,
defaultOpen,
...rest
}: UploadButtonViewSnapshot & UploadButtonViewActions): JSX.Element => {
}: UploadButtonViewSnapshot & UploadButtonViewActions & { defaultOpen: boolean }): JSX.Element => {
const vm = useMockedViewModel(rest, {
onUploadOptionSelected,
});
return <UploadButton vm={vm} />;
return <UploadButton defaultOpen={defaultOpen} vm={vm} />;
};
const UploadButtonWrapper = withViewDocs(UploadButtonWrapperImpl, UploadButton);
export default {
const meta = {
title: "Room/UploadButton",
component: UploadButtonWrapper,
tags: ["autodocs"],
args: {
mayUpload: true,
defaultOpen: false,
onUploadOptionSelected: fn(),
options: [
{
type: "local",
label: "Attachment",
icon: AttachmentIcon,
},
{
label: "Fun Button",
icon: ReactionIcon,
type: "fun",
},
],
},
} satisfies Meta<typeof UploadButtonWrapper>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Default: Story = {};
export const WithOneOption: Story = {
// No visible difference
tags: ["skip-test"],
args: {
options: [
{
type: "local",
@ -40,34 +67,28 @@ export default {
},
],
},
} satisfies Meta<typeof UploadButtonWrapper>;
const Template: StoryFn<typeof UploadButtonWrapper> = (args) => <UploadButtonWrapper {...args} />;
export const Default = Template.bind({});
Default.args = {
options: [
{
type: "local",
label: "Attachment",
icon: AttachmentIcon,
},
{
label: "Fun Button",
icon: ReactionIcon,
type: "fun",
},
],
};
export const WithOneOption = Template.bind({});
WithOneOption.args = {
options: [
{
type: "local",
label: "Attachment",
icon: AttachmentIcon,
export const WithOpen: Story = {
args: {
defaultOpen: true,
},
parameters: {
a11y: {
config: {
rules: [
{
// Menu contains a header which is invalid
id: "aria-required-children",
enabled: false,
},
{
// Menu pops open by default
id: "aria-hidden-focus",
enabled: false,
},
],
},
},
],
},
};

View File

@ -23,7 +23,7 @@ describe("UploadButton", () => {
it("can open the menu and select an option", async () => {
const onUploadOptionSelected = fn();
const { container, getByRole } = render(<Default onUploadOptionSelected={onUploadOptionSelected} />);
await userEvent.click(getByRole("button", { name: "Open attachment menu" }));
await userEvent.click(getByRole("button", { name: "Attachment" }));
expect(container).toMatchSnapshot();
await userEvent.click(screen.getByRole("menuitem", { name: "Fun Button" }));
expect(onUploadOptionSelected).toHaveBeenCalledWith("fun");
@ -33,7 +33,7 @@ describe("UploadButton", () => {
const onUploadOptionSelected = fn();
const { getByRole } = render(<Default onUploadOptionSelected={onUploadOptionSelected} />);
await userEvent.keyboard("[ControlLeft>]");
await userEvent.click(getByRole("button", { name: "Open attachment menu" }));
await userEvent.click(getByRole("button", { name: "Attachment" }));
expect(onUploadOptionSelected).toHaveBeenCalledWith("local");
});
});

View File

@ -23,7 +23,7 @@ import { useViewModel, type ViewModel } from "../../../core/viewmodel";
export interface UploadButtonViewSnapshot {
mayUpload: boolean;
options: { type: string; label: string; icon: ComponentType<SVGAttributes<SVGElement>> }[];
options: { type: string; label: string; icon?: ComponentType<SVGAttributes<SVGElement>> }[];
}
export interface UploadButtonViewActions {
@ -41,12 +41,15 @@ export interface UploadButtonViewActions {
*/
export function UploadButton({
vm,
defaultOpen = false,
...rootButtonProps
}: PropsWithChildren<
{ vm: ViewModel<UploadButtonViewSnapshot, UploadButtonViewActions> } & ComponentProps<typeof IconButton>
{ vm: ViewModel<UploadButtonViewSnapshot, UploadButtonViewActions>; defaultOpen?: boolean } & ComponentProps<
typeof IconButton
>
>): ReactElement {
const i18n = useI18n();
const [open, setOpen] = useState(false);
const [open, setOpen] = useState(defaultOpen);
const { options } = useViewModel(vm);
// Ctrl+click is a shortcut to selecting the first item.
// N.B. Clicking and shift clicking is handled by radix and
@ -68,10 +71,10 @@ export function UploadButton({
<IconButton
{...rootButtonProps}
tooltip={label}
title={label}
aria-label={label}
onClick={() => vm.onUploadOptionSelected(options[0].type)}
>
<Icon />
{Icon ? <Icon /> : <AttachmentIcon />}
</IconButton>
);
}

View File

@ -18,7 +18,7 @@ exports[`UploadButton > can open the menu and select an option 1`] = `
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Open attachment menu"
title="Attachment"
type="button"
>
<div
@ -55,7 +55,7 @@ exports[`UploadButton > renders a default button 1`] = `
role="button"
style="--cpd-icon-button-size: 32px;"
tabindex="0"
title="Open attachment menu"
title="Attachment"
type="button"
>
<div