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

Accessibility: mark up .input-button as semantic buttons #323

Merged
merged 3 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions component/src/views/chat/input/buttons/camera/cameraButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export class CameraButton extends InputButton<Styles> {
private static createButtonElement() {
const buttonElement = document.createElement('div');
buttonElement.classList.add('input-button');
buttonElement.role = 'button';
buttonElement.setAttribute('tabindex', '0');
return buttonElement;
}

Expand Down
3 changes: 2 additions & 1 deletion component/src/views/chat/input/buttons/inputButton.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
height: 1.65em;
}

.input-button:hover {
.input-button:hover,
.input-button:focus-visible {
background-color: #9c9c9c2e;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export class MicrophoneButton extends InputButton<Styles> {
const buttonElement = document.createElement('div');
buttonElement.id = 'microphone-button';
buttonElement.classList.add('input-button');
buttonElement.role = 'button';
buttonElement.setAttribute('tabindex', '0');
return buttonElement;
}

Expand Down
10 changes: 10 additions & 0 deletions component/src/views/chat/input/buttons/submit/submitButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export class SubmitButton extends InputButton<Styles> {
private static createButtonContainerElement() {
const buttonElement = document.createElement('div');
buttonElement.classList.add('input-button');
buttonElement.role = 'button';
buttonElement.setAttribute('tabindex', '0');
return buttonElement;
}

Expand Down Expand Up @@ -220,6 +222,8 @@ export class SubmitButton extends InputButton<Styles> {
private changeToStopIcon() {
if (this._serviceIO.websocket) return; // stop not used for streaming messages in websocket
this.elementRef.classList.remove(SubmitButton.LOADING_CLASS, SubmitButton.DISABLED_CLASS, SubmitButton.SUBMIT_CLASS);
this.elementRef.removeAttribute('aria-busy');
this.elementRef.removeAttribute('aria-disabled');
this.elementRef.replaceChildren(this._innerElements.stop);
this.reapplyStateStyle('stop', ['loading', 'submit']);
this.elementRef.onclick = this.stopStream.bind(this);
Expand All @@ -230,7 +234,9 @@ export class SubmitButton extends InputButton<Styles> {
if (this._serviceIO.websocket) return;
if (!this._isSVGLoadingIconOverriden) this.elementRef.replaceChildren(this._innerElements.loading);
this.elementRef.classList.remove(SubmitButton.SUBMIT_CLASS, SubmitButton.DISABLED_CLASS);
this.elementRef.removeAttribute('aria-disabled');
this.elementRef.classList.add(SubmitButton.LOADING_CLASS);
this.elementRef.setAttribute('aria-busy', 'true');
this.reapplyStateStyle('loading', ['submit']);
this.elementRef.onclick = () => {};
this.status.requestInProgress = true;
Expand All @@ -241,6 +247,8 @@ export class SubmitButton extends InputButton<Styles> {
public changeToSubmitIcon() {
if (this.elementRef.classList.contains(SubmitButton.SUBMIT_CLASS)) return;
this.elementRef.classList.remove(SubmitButton.LOADING_CLASS, SubmitButton.DISABLED_CLASS);
this.elementRef.removeAttribute('aria-busy');
this.elementRef.removeAttribute('aria-disabled');
this.elementRef.classList.add(SubmitButton.SUBMIT_CLASS);
this.elementRef.replaceChildren(this._innerElements.submit);
SubmitButtonStateStyle.resetSubmit(this, this.status.loadingActive);
Expand All @@ -258,7 +266,9 @@ export class SubmitButton extends InputButton<Styles> {
this.changeToSubmitIcon();
} else if (!this.elementRef.classList.contains(SubmitButton.DISABLED_CLASS)) {
this.elementRef.classList.remove(SubmitButton.LOADING_CLASS, SubmitButton.SUBMIT_CLASS);
this.elementRef.removeAttribute('aria-busy');
this.elementRef.classList.add(SubmitButton.DISABLED_CLASS);
this.elementRef.setAttribute('aria-disabled', 'true');
this.elementRef.replaceChildren(this._innerElements.disabled);
this.reapplyStateStyle('disabled', ['submit']);
this.elementRef.onclick = () => {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export class UploadFileButton extends InputButton<Styles> {
private static createButtonElement() {
const buttonElement = document.createElement('div');
buttonElement.classList.add('input-button', 'upload-file-button');
buttonElement.role = 'button';
buttonElement.setAttribute('tabindex', '0');
return buttonElement;
}

Expand Down
Loading