Make TabbedView a controlled component (#12480)
* Convert tabbedview to functional component The 'Tab' is still a class, so now it's a functional component that has a supporting class, which is maybe a bit... jarring, but I think is actually perfectly logical. * put comment back * Fix bad tab ID behaviour * Make TabbedView a controlled component This does mean the logic of keeping what tab is active is now in each container component, but for a functional component, this is a single line. It makes TabbedView simpler and the container components always know exactly what tab is being displayed rather than having to effectively keep the state separately themselves if they wanted it. Based on https://github.com/matrix-org/matrix-react-sdk/pull/12478 * Fix some types & unused prop * Remove weird behaviour of using first tab is active isn't valid * Don't pass initialTabID here now it no longer has the prop * Fix test * bleh... id, not icon * Change to sub-components and use contitional call syntax * Comments * Fix element IDs * Fix merge * Test DesktopCapturerSourcePicker to make sonarcloud the right colour * Use custom hook for the fllback tab behaviour
This commit is contained in:
parent
2f3c84f1f4
commit
9684dd5145
10 changed files with 170 additions and 95 deletions
|
@ -33,7 +33,6 @@ import SettingsSubsection, { SettingsSubsectionText } from "../settings/shared/S
|
|||
|
||||
interface IProps {
|
||||
space: Room;
|
||||
initialTabId?: SpacePreferenceTab;
|
||||
onFinished(): void;
|
||||
}
|
||||
|
||||
|
@ -68,7 +67,7 @@ const SpacePreferencesAppearanceTab: React.FC<Pick<IProps, "space">> = ({ space
|
|||
);
|
||||
};
|
||||
|
||||
const SpacePreferencesDialog: React.FC<IProps> = ({ space, initialTabId, onFinished }) => {
|
||||
const SpacePreferencesDialog: React.FC<IProps> = ({ space, onFinished }) => {
|
||||
const tabs: NonEmptyArray<Tab<SpacePreferenceTab>> = [
|
||||
new Tab(
|
||||
SpacePreferenceTab.Appearance,
|
||||
|
@ -90,7 +89,7 @@ const SpacePreferencesDialog: React.FC<IProps> = ({ space, initialTabId, onFinis
|
|||
<RoomName room={space} />
|
||||
</h4>
|
||||
<div className="mx_SettingsDialog_content">
|
||||
<TabbedView tabs={tabs} initialTabId={initialTabId} />
|
||||
<TabbedView tabs={tabs} activeTabId={SpacePreferenceTab.Appearance} onChange={() => {}} />
|
||||
</div>
|
||||
</BaseDialog>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue