Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Add label to OcSelect #1570

Merged
merged 3 commits into from
Sep 6, 2021
Merged

Add label to OcSelect #1570

merged 3 commits into from
Sep 6, 2021

Conversation

pascalwengerter
Copy link
Contributor

Description

See changelog item

@pascalwengerter
Copy link
Contributor Author

Cherrypicking this commit to master will close #1503

@pascalwengerter pascalwengerter requested review from kulmann and removed request for LukasHirt August 5, 2021 15:26
@@ -32,6 +35,11 @@ export default {
required: false,
default: null,
},
labelText: {
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to bind $attrs without the label prop to the vue-select? So that we can have a dedicated label prop on the OcSelect? I kind of dislike using labelText as prop name here, while we use label on all other form related elements.

Copy link
Member

Choose a reason for hiding this comment

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

Full ack! Streamline all the things 🥳

@pascalwengerter
Copy link
Contributor Author

@kulmann ready for re-review. Feels a bit hacky and prevents us from using the vue-select label prop but gets the job done

@@ -33,6 +42,11 @@ export default {
default: null,
},
},
computed: {
setLabel() {
Copy link
Contributor

Choose a reason for hiding this comment

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

i find this somehow misleading, sounds like a method. Maybe selectLabel?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about inputLabel? @kulmann any suggestions/opinions?

Copy link
Member

Choose a reason for hiding this comment

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

yeah, inputLabel is fine

@@ -42,6 +56,11 @@ export default {
const comboBoxElement = this.$refs.select.$el.querySelector("div:first-child")
comboBoxElement.setAttribute("aria-label", this.$gettext("Search for option"))
},
setCustomizedAttrs() {
Copy link
Member

Choose a reason for hiding this comment

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

This is not setting anything. It should be a computed prop (and have a different name, like customizedAttrs or something like that)

Copy link
Member

Choose a reason for hiding this comment

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

Also, you should copy the this.$attrs first before modifying.

@@ -0,0 +1,5 @@
Enhancement: Label for OcSelect

We've added a configurable `<label>` for the OcSelect label.
Copy link
Member

Choose a reason for hiding this comment

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

Tbh this sounds a bit strange.

You've just added a label for OcSelect, no?


We've added a configurable `<label>` for the OcSelect label.

https://github.com/owncloud/web/issues/1570
Copy link
Member

Choose a reason for hiding this comment

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

Should be #1503 I think

Copy link
Member

@dschmidt dschmidt Sep 3, 2021

Choose a reason for hiding this comment

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

Ah, nope - #1570 hehe

Number was right, just the wrong repo

Copy link
Member

@dschmidt dschmidt left a comment

Choose a reason for hiding this comment

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

IMHO this is a breaking change (I'm using the label property already) and should be marked as such in the changelog.
After all you had to change the documentation/example because it was broken ;-)

I would prefer having an option-label prop instead of having to use the option slot but that's obviously debatable.

Sometimes we need to display more complex options. This can include e.g. an option with a title and a description.
To still display all those values exactly as we want to, we need to use scoped slot called `option`.
We can then retrieve all the values that we want to display from the slots parametres.
It is important to use a `label` key inside the passed object since `oc-select` will look for it.
Copy link
Member

@dschmidt dschmidt Sep 3, 2021

Choose a reason for hiding this comment

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

This sounds rather complicated. Why don't we introduce an option-label property that will be passed as label to vue-select?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds like a great idea actually, let me take a look 🕵🏽

Copy link
Member

Choose a reason for hiding this comment

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

Or get it from $attrs fwiw

@dschmidt
Copy link
Member

dschmidt commented Sep 3, 2021

In general: yay!
With this we can replace one more ❌ with ✔️ in owncloud/web#8857 :-D
Much appreciated if you could do that once this gets merged.

return this.$attrs["label"]
/**
* Label of the select component
* ATTENTION: this shadows the vue-select option `label`. If you need access to that use `optionLabel`.
Copy link
Member

Choose a reason for hiding this comment

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

It shadows the vue select "prop"

<div slot="no-options" v-translate>No options available.</div>
</vue-select>
<div>
<label :for="this.$attrs['input-id']" v-text="label" />
Copy link
Member

Choose a reason for hiding this comment

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

Where is this supposed to come from? How is this wired up with vue-select?

Copy link
Member

Choose a reason for hiding this comment

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

Ah I assume vue-select has this prop? In other places we seem to use an id prop, maybe we should stick to that

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

@dschmidt
Copy link
Member

dschmidt commented Sep 4, 2021

CI fails because of unit tests, looks completely unrelated to me. OcSelect does not have unit tests after all :trollface:

@pascalwengerter
Copy link
Contributor Author

Squash-merging this into the a11y-updates branch now as it has the same changeset as #1633 (@dschmidt your review was implemented, thanks for the constructive feedback and collaboration!)

@pascalwengerter pascalwengerter merged commit 088159b into a11y-updates Sep 6, 2021
@delete-merged-branch delete-merged-branch bot deleted the label_for_ocSelect branch September 6, 2021 14:27
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants