-
-
Notifications
You must be signed in to change notification settings - Fork 79.2k
Use a streamlined way to trigger component dismiss #34170
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
Conversation
9f13899
to
7df1c1f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about defining enableDismissTrigger
on the base-component? That way you could use it like Plugin.enableDismissTrigger(callback)
and don't have to pass the plugin.
I don't know if it is ok to use it as static, as it will leave open the possibility to be called outside the code, causing fault usages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lines 144 to 146 in 34218da
if (event && ['A', 'AREA'].includes(event.target.tagName)) { | |
event.preventDefault() | |
} |
do we still need this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As we still support anchors with
Is better to merge #33402 before this MR, because existing alert code, does some 'magic', and makes me nervous, using other code After #33402 is merged, we won't have to solve this riddle |
But this is done by |
50e7b2e
to
81f3ce8
Compare
9191063
to
ef42102
Compare
d5c0310
to
f5b6c4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said in #33324, I'm a bit concerned about usability and accessibility. The refactor looks great, but use cases that it'd allow feel wrong.
Modal (and offcanvas) are supposed to make everything outside them inert while they're opened. Toast and alerts are IMHO valid use cases, but I'm not sure about this as a feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said in #33403, this might need technical docs. Depending on this, we may need to add a callout regarding accessibility risks, but I guess we're pretty safe as long as we don't promote weird use cases.
49b5fe9
to
f74c336
Compare
6f3d544
to
d998900
Compare
0256982
to
7304a4e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the consolidation of code and docs!
94e22ee
to
c68f809
Compare
c68f809
to
5a81c5d
Compare
* use a streamlined way to trigger component dismiss * add documentation Co-authored-by: XhmikosR <[email protected]>
Till this MR:
plugins that support dismiss action by clicking on a
data-bs-dismiss
trigger, can be dismissed ONLY if the trigger is inside the plugin html.Alert, makes the difference. Alert on
data-bs-dismiss
click, tries to parse adata-bs-target
element and in case in null, it fallback on the standard way, that assumes the trigger is inside the plugin htmlThis MR:
introduces the
enableDismissTrigger
helper function, that streamlines the functionality, using the idea of Alert component.When 'dismiss' is clicked, it searches for
getElementFromSelector(event.target) || this.closest(
.${Plugin.NAME})
.Result:
data-bs-target
it can be anywhere in docThe idea came from #33324