Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
957a4a65
Commit
957a4a65
authored
3 years ago
by
Reiter, Christoph
Browse files
Options
Downloads
Patches
Plain Diff
Fix some event handler leaks with person/organization-select
It was using the click event but never removed the event listener
parent
8c457e48
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/organization-select/src/organization-select.js
+14
-13
14 additions, 13 deletions
packages/organization-select/src/organization-select.js
packages/person-select/src/person-select.js
+17
-16
17 additions, 16 deletions
packages/person-select/src/person-select.js
with
31 additions
and
29 deletions
packages/organization-select/src/organization-select.js
+
14
−
13
View file @
957a4a65
...
@@ -25,6 +25,8 @@ export class OrganizationSelect extends AdapterLitElement {
...
@@ -25,6 +25,8 @@ export class OrganizationSelect extends AdapterLitElement {
this
.
cache
=
{};
this
.
cache
=
{};
this
.
value
=
''
;
this
.
value
=
''
;
this
.
context
=
''
;
this
.
context
=
''
;
this
.
_onDocumentClicked
=
this
.
_onDocumentClicked
.
bind
(
this
);
}
}
static
get
properties
()
{
static
get
properties
()
{
...
@@ -48,16 +50,13 @@ export class OrganizationSelect extends AdapterLitElement {
...
@@ -48,16 +50,13 @@ export class OrganizationSelect extends AdapterLitElement {
connectedCallback
()
{
connectedCallback
()
{
super
.
connectedCallback
();
super
.
connectedCallback
();
document
.
addEventListener
(
'
click
'
,
this
.
_onDocumentClicked
);
this
.
updateSelect2
();
this
.
updateSelect2
();
}
this
.
updateComplete
.
then
(()
=>
{
disconnectedCallback
()
{
// Close the popup when clicking outside of select2
document
.
removeEventListener
(
'
click
'
,
this
.
_onDocumentClicked
);
document
.
addEventListener
(
'
click
'
,
(
ev
)
=>
{
super
.
disconnectedCallback
();
if
(
!
ev
.
composedPath
().
includes
(
this
))
{
this
.
_closeSelect2
();
}
});
});
}
}
async
load_organizations
()
{
async
load_organizations
()
{
...
@@ -71,11 +70,13 @@ export class OrganizationSelect extends AdapterLitElement {
...
@@ -71,11 +70,13 @@ export class OrganizationSelect extends AdapterLitElement {
return
this
.
cache
[
this
.
lang
]
===
undefined
;
return
this
.
cache
[
this
.
lang
]
===
undefined
;
}
}
_closeSelect2
()
{
_onDocumentClicked
(
ev
)
{
const
$select
=
this
.
$
(
'
#
'
+
this
.
selectId
);
// Close the popup when clicking outside of select2
console
.
assert
(
$select
.
length
,
"
select2 missing
"
);
if
(
!
ev
.
composedPath
().
includes
(
this
))
{
if
(
this
.
select2IsInitialized
(
$select
))
{
const
$select
=
this
.
$
(
'
#
'
+
this
.
selectId
);
$select
.
select2
(
'
close
'
);
if
(
$select
.
length
&&
this
.
select2IsInitialized
(
$select
))
{
$select
.
select2
(
'
close
'
);
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
packages/person-select/src/person-select.js
+
17
−
16
View file @
957a4a65
...
@@ -44,6 +44,8 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
...
@@ -44,6 +44,8 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
this
.
showReloadButton
=
false
;
this
.
showReloadButton
=
false
;
this
.
reloadButtonTitle
=
''
;
this
.
reloadButtonTitle
=
''
;
this
.
showDetails
=
false
;
this
.
showDetails
=
false
;
this
.
_onDocumentClicked
=
this
.
_onDocumentClicked
.
bind
(
this
);
}
}
static
get
scopedElements
()
{
static
get
scopedElements
()
{
...
@@ -84,28 +86,27 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
...
@@ -84,28 +86,27 @@ export class PersonSelect extends ScopedElementsMixin(AdapterLitElement) {
connectedCallback
()
{
connectedCallback
()
{
super
.
connectedCallback
();
super
.
connectedCallback
();
const
that
=
this
;
document
.
addEventListener
(
'
click
'
,
this
.
_onDocumentClicked
)
;
this
.
updateComplete
.
then
(()
=>
{
this
.
updateComplete
.
then
(()
=>
{
that
.
$select
=
that
.
$
(
'
#
'
+
that
.
selectId
);
this
.
$select
=
this
.
$
(
'
#
'
+
this
.
selectId
);
// Close the popup when clicking outside of select2
document
.
addEventListener
(
'
click
'
,
(
ev
)
=>
{
if
(
!
ev
.
composedPath
().
includes
(
this
))
{
this
.
_closeSelect2
();
}
});
// try an init when user-interface is loaded
// try an init when user-interface is loaded
th
at
.
initJSONLD
();
th
is
.
initJSONLD
();
});
});
}
}
_closeSelect2
()
{
disconnectedCallback
()
{
const
$select
=
this
.
$
(
'
#
'
+
this
.
selectId
);
document
.
removeEventListener
(
'
click
'
,
this
.
_onDocumentClicked
);
console
.
assert
(
$select
.
length
,
"
select2 missing
"
);
super
.
disconnectedCallback
();
if
(
this
.
select2IsInitialized
(
$select
))
{
}
$select
.
select2
(
'
close
'
);
_onDocumentClicked
(
ev
)
{
// Close the popup when clicking outside of select2
if
(
!
ev
.
composedPath
().
includes
(
this
))
{
const
$select
=
this
.
$
(
'
#
'
+
this
.
selectId
);
if
(
$select
.
length
&&
this
.
select2IsInitialized
(
$select
))
{
$select
.
select2
(
'
close
'
);
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment