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

Fix: AccessibleButton does not set disabled attribute (PSF-1055) #8682

Merged
merged 8 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 0 additions & 8 deletions res/css/components/views/location/_ShareType.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ limitations under the License.
&:hover, &:focus {
border-color: $accent;
}

// this style is only during active development
// when lab is enabled but feature not fully implemented
// pin drop option will be disabled
&.mx_AccessibleButton_disabled {
pointer-events: none;
opacity: 0.4;
}
}

.mx_ShareType_option-icon {
Expand Down
5 changes: 5 additions & 0 deletions src/components/views/location/LocationPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,11 @@ class LocationPicker extends React.Component<ILocationPickerProps, IState> {
};

private onOk = () => {
// disabling button doesn't stop its handler
// don't submit without a position
if (!this.state.position) {
return;
}
const { timeout, position } = this.state;

this.props.onChoose(
Expand Down
22 changes: 22 additions & 0 deletions test/components/views/location/LocationPicker-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,28 @@ describe("LocationPicker", () => {
expect(wrapper.find('MemberAvatar').length).toBeTruthy();
});

it('disables submit button until geolocation completes', () => {
const onChoose = jest.fn();
const wrapper = getComponent({ shareType, onChoose });

// submit button is enabled when position is truthy
expect(findByTestId(wrapper, 'location-picker-submit-button').at(0).props().disabled).toBeTruthy();
act(() => {
findByTestId(wrapper, 'location-picker-submit-button').at(0).simulate('click');
});
// nothing happens on button click
expect(onChoose).not.toHaveBeenCalled();

act(() => {
// @ts-ignore
mocked(mockGeolocate).emit('geolocate', mockGeolocationPosition);
wrapper.setProps({});
});

// submit button is enabled when position is truthy
expect(findByTestId(wrapper, 'location-picker-submit-button').at(0).props().disabled).toBeFalsy();
});

it('submits location', () => {
const onChoose = jest.fn();
const wrapper = getComponent({ onChoose, shareType });
Expand Down