Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile: Fixes #9858: Fix deeply-nested subnotebook titles invisible in the folder dropdown #9906

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 14 additions & 4 deletions packages/app-mobile/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ type ValueType = string;
export interface DropdownListItem {
label: string;
value: ValueType;

// Depth corresponds with indentation and can be used to
// create tree structures.
depth?: number;
}

export type OnValueChangedListener = (newValue: ValueType)=> void;
Expand Down Expand Up @@ -67,6 +71,7 @@ class Dropdown extends Component<DropdownProps, DropdownState> {
const maxListTop = windowHeight - listHeight;
const listTop = Math.min(maxListTop, this.state.headerSize.y + this.state.headerSize.height);

const dropdownWidth = this.state.headerSize.width;
const wrapperStyle: ViewStyle = {
width: this.state.headerSize.width,
height: listHeight + 2, // +2 for the border (otherwise it makes the scrollbar appear)
Expand All @@ -86,11 +91,14 @@ class Dropdown extends Component<DropdownProps, DropdownState> {
const itemListStyle = { ...(this.props.itemListStyle ? this.props.itemListStyle : {}), borderWidth: 1,
borderColor: '#ccc' };

const itemWrapperStyle = { ...(this.props.itemWrapperStyle ? this.props.itemWrapperStyle : {}), flex: 1,
const itemWrapperStyle: ViewStyle = {
...(this.props.itemWrapperStyle ? this.props.itemWrapperStyle : {}),
flex: 1,
justifyContent: 'center',
height: itemHeight,
paddingLeft: 20,
paddingRight: 10 };
paddingRight: 10,
};

const headerWrapperStyle = { ...(this.props.headerWrapperStyle ? this.props.headerWrapperStyle : {}), height: 35,
flex: 1,
Expand Down Expand Up @@ -123,17 +131,19 @@ class Dropdown extends Component<DropdownProps, DropdownState> {

const itemRenderer = ({ item }: { item: DropdownListItem }) => {
const key = item.value ? item.value.toString() : '__null'; // The top item ("Move item to notebook...") has a null value.
const indentWidth = Math.min((item.depth ?? 0) * 32, dropdownWidth * 2 / 3);

return (
<TouchableOpacity
style={itemWrapperStyle as any}
style={itemWrapperStyle}
accessibilityRole="menuitem"
key={key}
onPress={() => {
closeList();
if (this.props.onValueChange) this.props.onValueChange(item.value);
}}
>
<Text ellipsizeMode="tail" numberOfLines={1} style={itemStyle} key={key}>
<Text ellipsizeMode="tail" numberOfLines={1} style={{ ...itemStyle, marginStart: indentWidth }} key={key}>
{item.label}
</Text>
</TouchableOpacity>
Expand Down
2 changes: 1 addition & 1 deletion packages/app-mobile/components/FolderPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const FolderPicker: FunctionComponent<FolderPickerProps> = ({
const f = folders[i];
const icon = Folder.unserializeIcon(f.icon);
const iconString = icon ? `${icon.emoji} ` : '';
pickerItems.push({ label: `${' '.repeat(indent)} ${iconString + Folder.displayTitle(f)}`, value: f.id });
pickerItems.push({ label: `${iconString + Folder.displayTitle(f)}`, depth: indent, value: f.id });
pickerItems = addFolderChildren(f.children, pickerItems, indent + 1);
}

Expand Down