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

Add accessible NcSelect and NcSelectTags components #3435

Merged
merged 8 commits into from
Nov 29, 2022

Conversation

Pytal
Copy link
Contributor

@Pytal Pytal commented Nov 5, 2022

  • Implement new component with https://github.com/sagalbot/vue-select for improved multiselect accessibility
  • Port NcMultiselectTags
  • Allow automatic wrapping to be disabled
  • Filter by displayName and subtitle on user option object when userSelect is enabled
  • Migrate NcMultiselect usage in this library to new API
    • NcSettingsSelectGroup
    • NcTimezonePicker
  • Document breaking changes
  • Add icon svg and title support to NcListItemIcon
  • Restore original NcMultiselect and NcMultiselectTags
  • Add NcSelect and NcSelectTags components
    • Deprecate NcMultiselect and NcMultiselectTags
Related changes

https://github.com/sagalbot/vue-select follows many accessibility best practices as described in https://vue-select.org/guide/accessibility.html but will require upstream pull requests to further enhance accessibility

@Pytal Pytal added the 2. developing Work in progress label Nov 5, 2022
@Pytal Pytal self-assigned this Nov 5, 2022
@Pytal Pytal mentioned this pull request Nov 8, 2022
7 tasks
@Pytal Pytal force-pushed the enh/a11y-multiselect branch 8 times, most recently from 5911015 to ce923be Compare November 16, 2022 02:40
@Pytal Pytal changed the title [WIP] Add accessible multiselect Add accessible multiselect Nov 16, 2022
@Pytal Pytal marked this pull request as ready for review November 16, 2022 02:52
@Pytal Pytal added enhancement New feature or request 3. to review Waiting for reviews feature: select Related to the NcSelect* components accessibility Making sure we design for the widest range of people possible, including those who have disabilities and removed 2. developing Work in progress labels Nov 16, 2022
@Pytal Pytal added this to the 8.0.0 milestone Nov 16, 2022
@Pytal

This comment was marked as outdated.

@skjnldsv skjnldsv added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Nov 17, 2022
@Pytal Pytal added the 3. to review Waiting for reviews label Nov 19, 2022
@Pytal
Copy link
Contributor Author

Pytal commented Nov 19, 2022

New NcSelect and NcSelectTags components ready for code review with interactive examples at https://deploy-preview-3435--nextcloud-vue-components.netlify.app/#/Components/NcSelect

src/components/NcListItemIcon/NcIcon.vue Outdated Show resolved Hide resolved
src/components/NcListItemIcon/NcIcon.vue Outdated Show resolved Hide resolved
src/components/NcListItemIcon/NcIcon.vue Outdated Show resolved Hide resolved
src/components/NcSelect/NcSelect.vue Outdated Show resolved Hide resolved
src/components/NcSelect/NcSelect.vue Outdated Show resolved Hide resolved
src/components/NcSelectTags/api.js Show resolved Hide resolved
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>
@Pytal Pytal modified the milestones: 8.0.0, 7.2.0 Nov 23, 2022
import logger from '../../utils/logger.js'

export default {
name: 'NcIconSvgWrapper',
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any thoughts @skjnldsv?

Copy link
Contributor

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 :)

Copy link
Contributor Author

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?

Copy link
Contributor

@artonge artonge left a 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 :)

@Pytal
Copy link
Contributor Author

Pytal commented Nov 23, 2022

  • Test component as sharing input in server

Comment on lines +71 to +95
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
},
Copy link
Contributor

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

Copy link
Contributor Author

@Pytal Pytal Nov 26, 2022

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

Copy link
Contributor

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!

Copy link
Contributor

@skjnldsv skjnldsv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comments

@Pytal Pytal requested a review from skjnldsv November 26, 2022 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews accessibility Making sure we design for the widest range of people possible, including those who have disabilities enhancement New feature or request feature: select Related to the NcSelect* components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants