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

fix(NcSelect): Fix disabled state of NcSelect with dark mode #4079

Merged
merged 1 commit into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/components/NcSelect/NcSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -945,6 +945,9 @@ body {
--vs-state-disabled-color: var(--color-text-maxcontrast);
--vs-state-disabled-controls-color: var(--color-text-maxcontrast);
--vs-state-disabled-cursor: not-allowed;
--vs-disabled-bg: var(--color-background-dark);
Copy link
Contributor

@Antreesy Antreesy May 10, 2023

Choose a reason for hiding this comment

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

Aliases --vs-state-disabled-* should update this value, but maybe it's not hapenning because of the css rules order, so I guess, it's legal to override here

--vs-disabled-color: var(--color-text-maxcontrast);
--vs-disabled-cursor: not-allowed;
Comment on lines +948 to +950
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 the --vs-state-disabled-* variables are already set above and are aliased to these variables internally https://github.com/nextcloud-deps/vue-select/blob/9294fdcbf39380fd5cc766144b18b6f86cf107f4/src/css/global/states.css#L13C35-L15

Is this solvable without adding non-publicly documented variables https://vue-select.org/guide/css.html#available-css-variables-3-18?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no clue why, but it fixes it. As per #4079 (comment) it could be the order, since --vs-disabled-bg: var(--vs-state-disabled-bg); is not a permanent redirect, but it writes the currently value of the second var into the first one. So maybe we only replace the --vs-state-disabled-bg after that and therefore also need to overwrite the first var

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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 this happens because:
--vs-disabled-bg: var(--vs-state-disabled-bg); from vue-select if on the :root selector.

And our --vs-state-disabled-bg: var(--color-background-dark); is on the body selector.

So when --vs-disabled-bg is set, the --vs-state-disabled-bg variable holds the old value.

Copy link
Contributor

Choose a reason for hiding this comment

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

So I think it has the same cause as this one: nextcloud/server#36462


/* Borders */
--vs-border-color: var(--color-border-maxcontrast);
Expand Down Expand Up @@ -998,13 +1001,13 @@ body {
margin-right: 2px;
}

&.vs--open .vs__dropdown-toggle {
border-color: var(--color-primary);
&.vs--open .vs__dropdown-toggle:not([disabled]) {
border-color: var(--color-primary-element);
Antreesy marked this conversation as resolved.
Show resolved Hide resolved
border-bottom-color: transparent;
}

&:not(.vs--open) .vs__dropdown-toggle:hover {
border-color: var(--color-primary);
&:not(.vs--open) .vs__dropdown-toggle:hover:not([disabled]) {
border-color: var(--color-primary-element);
}

&--no-wrap {
Expand All @@ -1019,7 +1022,7 @@ body {
.vs__dropdown-toggle {
border-radius: 0 0 var(--vs-border-radius) var(--vs-border-radius);
border-top-color: transparent;
border-bottom-color: var(--color-primary);
border-bottom-color: var(--color-primary-element);
}
}
}
Expand Down