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

Improved maintanance of popups visibility #2809

Merged
merged 3 commits into from
Feb 20, 2021
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Bumped nuclio version to 1.5.16
- All methods for interative segmentation accept negative points as well
- Persistent queue added to logstash (<https://github.com/openvinotoolkit/cvat/pull/2744>)
- Improved maintanance of popups visibility (<https://github.com/openvinotoolkit/cvat/pull/2809>)

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.14.2",
"version": "1.14.3",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export default function withVisibilityHandling(WrappedComponent: typeof Popover,
return (props: PopoverProps): JSX.Element => {
const [initialized, setInitialized] = useState<boolean>(false);
const [visible, setVisible] = useState<boolean>(false);
let { overlayClassName } = props;
if (typeof overlayClassName !== 'string') overlayClassName = '';
const { overlayClassName, ...rest } = props;
const overlayClassNames = typeof overlayClassName === 'string' ? overlayClassName.split(/\s+/) : [];

overlayClassName += ` cvat-${popoverType}-popover`;
const popoverClassName = `cvat-${popoverType}-popover`;
overlayClassNames.push(popoverClassName);
if (visible) {
overlayClassName += ` cvat-${popoverType}-popover-visible`;
const visiblePopoverClassName = `cvat-${popoverType}-popover-visible`;
overlayClassNames.push(visiblePopoverClassName);
}

const callback = (event: Event): void => {
Expand All @@ -25,10 +27,19 @@ export default function withVisibilityHandling(WrappedComponent: typeof Popover,

return (
<WrappedComponent
{...props}
overlayClassName={overlayClassName.trim()}
{...rest}
trigger={visible ? 'click' : 'hover'}
overlayClassName={overlayClassNames.join(' ').trim()}
onVisibleChange={(_visible: boolean) => {
if (!_visible) setVisible(false);
if (!_visible) {
setVisible(false);
} else {
// Hide other popovers
const element = window.document.getElementsByClassName(`${popoverClassName}`)[0];
if (element) {
element.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
}
}
if (!initialized) {
const self = window.document.getElementsByClassName(`cvat-${popoverType}-popover`)[0];
self?.addEventListener('animationend', callback);
Expand Down