-
Notifications
You must be signed in to change notification settings - Fork 93
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
Add accessible NcSelect and NcSelectTags components #3435
Conversation
092ae5e
to
83ee0ff
Compare
5911015
to
ce923be
Compare
This comment was marked as outdated.
This comment was marked as outdated.
New NcSelect and NcSelectTags components ready for code review with interactive examples at https://deploy-preview-3435--nextcloud-vue-components.netlify.app/#/Components/NcSelect |
Signed-off-by: Christopher Ng <chrng8@gmail.com>
- Import from '@mdi/svg/svg/icon.svg?raw' Signed-off-by: Christopher Ng <chrng8@gmail.com>
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Signed-off-by: Christopher Ng <chrng8@gmail.com>
- Deprecate NcMultiselect component - Extract shared NcEllipsisedOption component Signed-off-by: Christopher Ng <chrng8@gmail.com>
- Deprecate NcMultiselectTags component Signed-off-by: Christopher Ng <chrng8@gmail.com>
Signed-off-by: Christopher Ng <chrng8@gmail.com>
Signed-off-by: Christopher Ng <chrng8@gmail.com>
3826acb
to
b700ce6
Compare
import logger from '../../utils/logger.js' | ||
|
||
export default { | ||
name: 'NcIconSvgWrapper', |
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.
I think is makes sense to expose this component publicly. I had to use @skjnldsv/sanitize-svg
, and I've seen a few other places where it was used too.
An opinion @skjnldsv ? with your expertise on your package and on icons :D
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.
Any thoughts @skjnldsv?
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.
Yep, you can have <script> inside an svg. So We need to sanitise them :)
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.
👍 already sanitized @skjnldsv, in https://github.com/nextcloud/nextcloud-vue/blob/enh/a11y-multiselect/src/components/NcListItemIcon/NcIconSvgWrapper.vue#L68
@artonge was wondering whether or not we should expose this component publicly?
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.
Good for me.
The comment about having NcIconSvgWrapper
public can be ignored for merging, as we can always do it later :)
|
renderHtmlString() { | ||
if (!this.cleanSvg) { | ||
return | ||
} | ||
|
||
const parser = new DOMParser() | ||
const parsedDocument = parser.parseFromString(this.cleanSvg, 'image/svg+xml') | ||
|
||
const errorNode = parsedDocument.querySelector('parsererror') | ||
if (errorNode) { | ||
logger.error(t('Error parsing svg'), errorNode) | ||
} | ||
const element = parsedDocument.documentElement | ||
element.classList.add('icon-vue__svg') | ||
|
||
if (this.title) { | ||
const titleElement = document.createElement('title') | ||
titleElement.textContent = this.title | ||
if (element.firstElementChild) { | ||
element.firstElementChild.prepend(titleElement) | ||
} | ||
} | ||
|
||
this.htmlString = element.outerHTML | ||
}, |
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.
Isn't it going too far?
We can just target the svg tag within via .icon-vue svg
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.
The primary purpose of this snippet is to add the accessible title element similar to https://github.com/robcresswell/vue-material-design-icons/blob/5.1.2/build.ts#L26 and thought that we might as well add the class as good practice due to the increased specificity of classes over tags
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.
Not sure about performances though.
I think doing it from update()
or mounted()
and just appending the title or updating if already exists would be more efficient :)
But that can be a followup!
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.
see comments
displayName
andsubtitle
on user option object whenuserSelect
is enabledDocument breaking changesRelated changes