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

fix(react-components): tooltip still active when hovering over child elements #4750

Merged
merged 1 commit into from
Sep 10, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 35 additions & 35 deletions react-components/src/components/Architecture/FilterButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,40 +101,40 @@ export const FilterButton = ({
return <></>;
}
return (
<CogsTooltip
content={<LabelWithShortcut label={label} command={command} />}
disabled={usedInSettings || label === undefined}
appendTo={document.body}
placement={placement}>
<Dropdown
visible={isOpen}
hideOnSelect={false}
appendTo={'parent'}
placement={usedInSettings ? 'bottom-end' : 'auto-start'}
content={
<div ref={menuRef}>
<Menu
style={{
minWidth: '100px',
overflow: 'auto',
flexDirection
<Dropdown
visible={isOpen}
hideOnSelect={false}
appendTo={'parent'}
placement={usedInSettings ? 'bottom-end' : 'auto-start'}
content={
<div ref={menuRef}>
<Menu
style={{
minWidth: '100px',
overflow: 'auto',
flexDirection
}}>
<Menu.Item
key={-1}
toggled={isAllChecked}
onClick={() => {
command.toggleAllChecked();
}}>
<Menu.Item
key={-1}
toggled={isAllChecked}
onClick={() => {
command.toggleAllChecked();
}}>
{BaseFilterCommand.getAllString(t)}
</Menu.Item>
<StyledMenuItems>
{children.map((child, _index): ReactElement => {
return <FilterItem key={child.uniqueId} command={child} />;
})}
</StyledMenuItems>
</Menu>
</div>
}>
{BaseFilterCommand.getAllString(t)}
</Menu.Item>
<StyledMenuItems>
{children.map((child, _index): ReactElement => {
return <FilterItem key={child.uniqueId} command={child} />;
})}
</StyledMenuItems>
</Menu>
</div>
}>
<CogsTooltip
content={<LabelWithShortcut label={label} command={command} />}
disabled={usedInSettings || label === undefined}
appendTo={document.body}
placement={placement}>
<Button
type={usedInSettings ? 'tertiary' : getButtonType(command)}
icon={usedInSettings ? (isOpen ? 'ChevronUp' : 'ChevronDown') : icon}
Expand All @@ -154,8 +154,8 @@ export const FilterButton = ({
}}>
{usedInSettings ? selectedLabel : undefined}
</Button>
</Dropdown>
</CogsTooltip>
</CogsTooltip>
</Dropdown>
);
};

Expand Down
52 changes: 26 additions & 26 deletions react-components/src/components/Architecture/OptionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,30 +89,30 @@ export const OptionButton = ({
const selectedLabel = command.selectedChild?.getLabel(t);

return (
<CogsTooltip
content={<LabelWithShortcut label={label} command={command} />}
disabled={usedInSettings || label === undefined}
appendTo={document.body}
placement={placement}>
<Dropdown
visible={isOpen}
hideOnSelect={true}
appendTo={'parent'}
placement={usedInSettings ? 'bottom-end' : 'auto-start'}
content={
<div ref={menuRef}>
<Menu
style={{
minWidth: '0px',
overflow: 'auto',
flexDirection
}}>
{children.map((child, _index): ReactElement => {
return createMenuItem(child, t, postAction);
})}
</Menu>
</div>
}>
<Dropdown
visible={isOpen}
hideOnSelect={true}
appendTo={'parent'}
placement={usedInSettings ? 'bottom-end' : 'auto-start'}
content={
<div ref={menuRef}>
<Menu
style={{
minWidth: '0px',
overflow: 'auto',
flexDirection
}}>
{children.map((child, _index): ReactElement => {
return createMenuItem(child, t, postAction);
})}
</Menu>
</div>
}>
<CogsTooltip
content={<LabelWithShortcut label={label} command={command} />}
disabled={usedInSettings || label === undefined}
appendTo={document.body}
placement={placement}>
<Button
style={{
padding: usedInSettings ? DEFAULT_PADDING : '8px 4px',
Expand All @@ -132,8 +132,8 @@ export const OptionButton = ({
}}>
{selectedLabel}
</Button>
</Dropdown>
</CogsTooltip>
</CogsTooltip>
</Dropdown>
);
};

Expand Down
50 changes: 25 additions & 25 deletions react-components/src/components/Architecture/SettingsButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,29 +101,29 @@ export const SettingsButton = ({
const children = command.children;

return (
<CogsTooltip
content={<LabelWithShortcut label={label} command={command} />}
disabled={label === undefined}
appendTo={document.body}
placement={placement}>
<Dropdown
visible={isOpen}
hideOnSelect={false}
appendTo={'parent'}
placement="auto-start"
content={
<div ref={menuRef}>
<Menu
style={{
flexDirection,
padding: DEFAULT_PADDING
}}>
{children.map((child, _index): ReactElement | undefined => {
return createMenuItem(child, t);
})}
</Menu>
</div>
}>
<Dropdown
visible={isOpen}
hideOnSelect={false}
appendTo={'parent'}
placement="auto-start"
content={
<div ref={menuRef}>
<Menu
style={{
flexDirection,
padding: DEFAULT_PADDING
}}>
{children.map((child, _index): ReactElement | undefined => {
return createMenuItem(child, t);
})}
</Menu>
</div>
}>
<CogsTooltip
content={<LabelWithShortcut label={label} command={command} />}
disabled={label === undefined}
appendTo={document.body}
placement={placement}>
<Button
type={getButtonType(command)}
icon={icon}
Expand All @@ -138,8 +138,8 @@ export const SettingsButton = ({
setOpen((prevState) => !prevState);
}}
/>
</Dropdown>
</CogsTooltip>
</CogsTooltip>
</Dropdown>
);
};

Expand Down
32 changes: 16 additions & 16 deletions react-components/src/components/RevealToolbar/HelpButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@ export const HelpButton = ({ fallbackLanguage }: HelpButtonProps): ReactElement
const [helpActive, setHelpActive] = useState<boolean>(false);

return (
<CogsTooltip content={t('HELP_TOOLTIP', 'Help')} placement="right" appendTo={document.body}>
<Dropdown
appendTo={document.body}
onClickOutside={() => {
setHelpActive(false);
}}
content={
<StyledMenu>
<MouseNavigation fallbackLanguage={fallbackLanguage} />
<KeyboardNavigation fallbackLanguage={fallbackLanguage} />
<TouchNavigation fallbackLanguage={fallbackLanguage} />
</StyledMenu>
}
placement="right">
<Dropdown
appendTo={document.body}
onClickOutside={() => {
setHelpActive(false);
}}
content={
<StyledMenu>
<MouseNavigation fallbackLanguage={fallbackLanguage} />
<KeyboardNavigation fallbackLanguage={fallbackLanguage} />
<TouchNavigation fallbackLanguage={fallbackLanguage} />
</StyledMenu>
}
placement="right">
<CogsTooltip content={t('HELP_TOOLTIP', 'Help')} placement="right" appendTo={document.body}>
<Button
type="ghost"
icon="Help"
Expand All @@ -43,8 +43,8 @@ export const HelpButton = ({ fallbackLanguage }: HelpButtonProps): ReactElement
setHelpActive((prevState) => !prevState);
}}
/>
</Dropdown>
</CogsTooltip>
</CogsTooltip>
</Dropdown>
);
};

Expand Down
20 changes: 10 additions & 10 deletions react-components/src/components/RevealToolbar/LayersButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ export const LayersButton = ({
);

return (
<CogsTooltip
content={t('LAYERS_FILTER_TOOLTIP', 'Filter 3D resource layers')}
placement="right"
appendTo={document.body}>
<Dropdown
appendTo={viewer.domElement ?? document.body}
content={<LayersContainer modelHandlers={modelLayerHandlers} update={update} />}
placement="right-start">
<Dropdown
appendTo={viewer.domElement ?? document.body}
content={<LayersContainer modelHandlers={modelLayerHandlers} update={update} />}
placement="right-start">
<CogsTooltip
content={t('LAYERS_FILTER_TOOLTIP', 'Filter 3D resource layers')}
placement="right"
appendTo={document.body}>
<Button type="ghost" icon="Layers" aria-label="3D Resource layers" />
</Dropdown>
</CogsTooltip>
</CogsTooltip>
</Dropdown>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -123,51 +123,51 @@ export const RuleBasedOutputsButton = ({

return (
<>
<CogsTooltip
content={t('RULESET_SELECT_HEADER', 'Select color overlay')}
placement="right"
appendTo={document.body}>
<Dropdown
placement="right-start"
disabled={isAssetMappingsLoading}
content={
<Menu
style={{
maxHeight: 300,
overflow: 'auto',
marginBottom: '20px'
}}>
<Menu.Header>{t('RULESET_SELECT_HEADER', 'Select color overlay')}</Menu.Header>
<Dropdown
placement="right-start"
disabled={isAssetMappingsLoading}
content={
<Menu
style={{
maxHeight: 300,
overflow: 'auto',
marginBottom: '20px'
}}>
<Menu.Header>{t('RULESET_SELECT_HEADER', 'Select color overlay')}</Menu.Header>
<RuleBasedSelectionItem
key="no-rule-selected"
id="no-rule-selected"
label={t('RULESET_NO_SELECTION', 'No RuleSet selected')}
checked={currentRuleSetEnabled === undefined || emptyRuleSelected?.isEnabled}
onChange={onChange}
isLoading={isRuleLoading}
isEmptyRuleItem={true}
/>
{ruleInstances?.map((item) => (
<RuleBasedSelectionItem
key="no-rule-selected"
id="no-rule-selected"
label={t('RULESET_NO_SELECTION', 'No RuleSet selected')}
checked={currentRuleSetEnabled === undefined || emptyRuleSelected?.isEnabled}
key={item?.rule?.properties.id}
id={item?.rule?.properties.id}
label={item?.rule?.properties.name}
checked={item?.isEnabled}
onChange={onChange}
isLoading={isRuleLoading}
isEmptyRuleItem={true}
isEmptyRuleItem={false}
/>
{ruleInstances?.map((item) => (
<RuleBasedSelectionItem
key={item?.rule?.properties.id}
id={item?.rule?.properties.id}
label={item?.rule?.properties.name}
checked={item?.isEnabled}
onChange={onChange}
isLoading={isRuleLoading}
isEmptyRuleItem={false}
/>
))}
</Menu>
}>
))}
</Menu>
}>
<CogsTooltip
content={t('RULESET_SELECT_HEADER', 'Select color overlay')}
placement="right"
appendTo={document.body}>
<Button
disabled={isAssetMappingsLoading}
icon="ColorPalette"
aria-label="Select RuleSet"
type="ghost"
/>
</Dropdown>
</CogsTooltip>
</CogsTooltip>
</Dropdown>
{ruleInstances !== undefined && ruleInstances?.length > 0 && (
<RuleBasedOutputsSelector
onRuleSetChanged={ruleSetStylingChanged}
Expand Down
Loading
Loading